Compare commits

...

3 Commits

Author SHA1 Message Date
fe399cabea v0.4.1 2022-08-25 17:01:42 +01:00
d90cf94259 Fix type annotations 2022-08-25 17:01:39 +01:00
a4fb98ad52 Fixes after publishing 2022-08-25 16:14:27 +01:00
4 changed files with 6 additions and 21 deletions

View File

@ -19,25 +19,10 @@ like the sync `Client`. Methods are *not* coroutines, they are non-blocking fun
`await`. The only exception is accessing messages through `async for`.
### Example
```python
import paho.mqtt.client as mqtt
import trio
from trio_paho_mqtt import AsyncClient
Please see `example.py` for a working example!
(example in README removed because it was not working)
async def handle_messages(client):
async for msg in client.messages():
print(f"Received msg: {msg}")
async with trio.open_nursery() as nursery:
sync_client = mqtt.Client()
client = AsyncClient(sync_client, nursery)
client.connect('mqtt.eclipse.org', 1883, 60)
client.subscribe(topic)
client.publish(topic, msg)
nursery.start_soon(handle_messages, client)
```
## Related projects
- [gmqtt](https://github.com/wialon/gmqtt) - Uses asyncio and callbacks. Isn't compatible with trio.

View File

@ -1,9 +1,9 @@
[tool.poetry]
name = "trio-paho-mqtt-up1"
version = "0.4.0"
version = "0.4.1"
description = "MQTT support for the Trio async runtime using Paho (update fork)"
authors = ["Olivier (fork) <triopahomqtt.python@librepush.net>", "bkanuka (original maintainer) <bkanuka@gmail.com>"]
license = "Apache2"
license = "Apache-2.0"
readme = "README.md"
packages = [{include = "trio_paho_mqtt"}]

View File

@ -5,12 +5,12 @@ from typing import Any, AsyncGenerator, Generator, List, Optional
import paho.mqtt.client as mqtt
import trio
from paho.mqtt.client import MQTTMessage
from paho.mqtt.properties import Properties
from paho.mqtt.reasoncodes import ReasonCodes
from trio import CancelScope, MemoryReceiveChannel, MemorySendChannel
# TODO
Message = Any
Message = MQTTMessage
class AsyncClient:

0
trio_paho_mqtt/py.typed Normal file
View File