Commit 9638518
fix(gateway): dispatch MQTT publishes onto the owning event loop
Every gateway control write (set_reserve, set_charge_rate, slot times, ...)
reaches GatewayMQTT via ha.py::run_async(), which runs the call chain on a
fresh, throwaway event loop distinct from the persistent loop that owns
GatewayMQTT's aiomqtt Client. Calling client.publish() from that other loop
binds the QoS-1 publish-confirmation Future to the wrong loop, so every
control write stalls for the client's ~10s default timeout before
completing — confirmed with a live reproduction against a local broker
(10.001s cross-loop vs 0.001s same-loop).
_publish_raw() now detects when it's running on a different loop than the
one captured from run() and hands the actual publish off via
run_coroutine_threadsafe, so it executes on the owning loop instead.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>1 parent f2d87f5 commit 9638518
2 files changed
Lines changed: 75 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
247 | 254 | | |
248 | 255 | | |
249 | 256 | | |
| |||
536 | 543 | | |
537 | 544 | | |
538 | 545 | | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
539 | 549 | | |
540 | 550 | | |
541 | 551 | | |
| |||
1622 | 1632 | | |
1623 | 1633 | | |
1624 | 1634 | | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
1625 | 1644 | | |
1626 | 1645 | | |
1627 | 1646 | | |
1628 | 1647 | | |
1629 | 1648 | | |
1630 | | - | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
1631 | 1659 | | |
1632 | 1660 | | |
1633 | 1661 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4440 | 4440 | | |
4441 | 4441 | | |
4442 | 4442 | | |
| 4443 | + | |
| 4444 | + | |
| 4445 | + | |
| 4446 | + | |
| 4447 | + | |
| 4448 | + | |
| 4449 | + | |
| 4450 | + | |
| 4451 | + | |
| 4452 | + | |
| 4453 | + | |
| 4454 | + | |
| 4455 | + | |
| 4456 | + | |
| 4457 | + | |
| 4458 | + | |
| 4459 | + | |
| 4460 | + | |
| 4461 | + | |
| 4462 | + | |
| 4463 | + | |
| 4464 | + | |
| 4465 | + | |
| 4466 | + | |
| 4467 | + | |
| 4468 | + | |
| 4469 | + | |
| 4470 | + | |
| 4471 | + | |
| 4472 | + | |
| 4473 | + | |
| 4474 | + | |
| 4475 | + | |
| 4476 | + | |
| 4477 | + | |
| 4478 | + | |
| 4479 | + | |
| 4480 | + | |
| 4481 | + | |
| 4482 | + | |
| 4483 | + | |
| 4484 | + | |
| 4485 | + | |
| 4486 | + | |
| 4487 | + | |
4443 | 4488 | | |
4444 | 4489 | | |
4445 | 4490 | | |
| |||
4476 | 4521 | | |
4477 | 4522 | | |
4478 | 4523 | | |
| 4524 | + | |
4479 | 4525 | | |
4480 | 4526 | | |
4481 | 4527 | | |
| |||
0 commit comments