[Twisted-Python] Mixing async/await and asyncio
![](https://secure.gravatar.com/avatar/5682179f6924a43d371803f892fc8265.jpg?s=120&d=mm&r=g)
I want to learn how to use twisted together with asyncio. I create several files to describe my problem https://gist.github.com/whalebot-helmsman/c400eb66c0bd35e406de3f8f704adf13: - I can use pure asyncio for simple case (asyncio_ex.py) - I can use pure twisted for simple case (twisted_ex.py) - I can await in twisted on twsited defer (twisted_await.py) I have a problem in case I try to await in twisted for asyncio coroutine(twisted_await_asyncio.py). Program never finishes and I got only started messages 2018-09-19 12:48:59,633 [WARNING] PID:8238 /home/nikita/tmp/twisted_await_asyncio.py:12 started 2018-09-19 12:48:59,633 [WARNING] PID:8238 /home/nikita/tmp/twisted_await_asyncio.py:12 started
![](https://secure.gravatar.com/avatar/d3dd3ba5cbd197a5927366c6c9a5003d.jpg?s=120&d=mm&r=g)
On September 19, 2018 8:50:41 AM EDT, "whalebot.helmsman@gmail.com" <whalebot.helmsman@gmail.com> wrote:
I can't say I've done this but I think this page is on topic. https://meejah.ca/blog/python3-twisted-and-asyncio Cheers, -kyle
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
On Sep 19, 2018, at 5:50 AM, whalebot.helmsman@gmail.com <mailto:whalebot.helmsman@gmail.com> wrote:
Your code is mostly correct, but you are running the default Twisted reactor. You need to use the asyncio reactor. The article Kyle linked to (https://meejah.ca/blog/python3-twisted-and-asyncio <https://meejah.ca/blog/python3-twisted-and-asyncio>) describes the necessary set-up. Hopefully in the future this will be more automatic! -g
![](https://secure.gravatar.com/avatar/d3dd3ba5cbd197a5927366c6c9a5003d.jpg?s=120&d=mm&r=g)
On September 19, 2018 8:50:41 AM EDT, "whalebot.helmsman@gmail.com" <whalebot.helmsman@gmail.com> wrote:
I can't say I've done this but I think this page is on topic. https://meejah.ca/blog/python3-twisted-and-asyncio Cheers, -kyle
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
On Sep 19, 2018, at 5:50 AM, whalebot.helmsman@gmail.com <mailto:whalebot.helmsman@gmail.com> wrote:
Your code is mostly correct, but you are running the default Twisted reactor. You need to use the asyncio reactor. The article Kyle linked to (https://meejah.ca/blog/python3-twisted-and-asyncio <https://meejah.ca/blog/python3-twisted-and-asyncio>) describes the necessary set-up. Hopefully in the future this will be more automatic! -g
participants (3)
-
Glyph
-
Kyle Altendorf
-
whalebot.helmsman@gmail.com