0

Suppose we have some asyncio Protocol running. And I need, for example, create Transport to specific socket adress from Protocol handler.

This operation is async. But protocol handler is an ordinary function. We cannot call something like run_until_complete, because loop is already running.

Is there any way to solve this? I hope there is something cleaner, than creating another Task with Queue to it.

uhbif19
  • 2,978
  • 3
  • 24
  • 47
  • 1
    simple approach: https://stackoverflow.com/questions/29126340/calling-a-coroutine-from-asyncio-protocol-data-received and more advance one: https://stackoverflow.com/questions/20746619/calling-coroutines-in-asyncio-protocol-data-received (with comment why) – kwarunek Sep 18 '17 at 07:55
  • @kwarunek Thanks! Now I see, my question is a duplicate. – uhbif19 Sep 18 '17 at 15:52
  • Maybe somebody find this topic useful: https://stackoverflow.com/questions/30937042/asyncio-persisent-client-protocol-class-using-queue/30940625#30940625 – user24502 Dec 13 '17 at 00:24

0 Answers0