[issue42445] Assertion in run_coroutine_threadsafe

2020-11-24 Thread Andrew Svetlov
Andrew Svetlov added the comment: "got Future attached to a different loop" means exactly what it says: you create a future object in one loop but awaits it in the different one. This is a programming error. Most likely the error in your script, not in mqtt and definitely not in asyncio. S

[issue42445] Assertion in run_coroutine_threadsafe

2020-11-24 Thread Jochen Kienzle
Jochen Kienzle added the comment: Thanks for your reply. I already tried asyncio.run(self.mqtt_client.publish_json(INGESTION_TOPIC, msg)) but this leads (rarely) to the following error: got Future attac

[issue42445] Assertion in run_coroutine_threadsafe

2020-11-23 Thread Andrew Svetlov
Andrew Svetlov added the comment: Transferring the loop instance between threads is not safe. You should create a loop and after that call run_forever() in the same thread. Or, even better, call asynxio.run() in a thread. -- ___ Python tracker

[issue42445] Assertion in run_coroutine_threadsafe

2020-11-23 Thread Jochen Kienzle
New submission from Jochen Kienzle : Hello, in my implementation I want to call mqtt_client.publish_json from a sync method: - def __on_event(self, ev): ... asyncio.run_coroutine_threadsafe(self.mqtt_client.publish_json(INGESTION_TOPIC, msg), loop=self.pub