0

I need to schedule and await coroutine in non-async function. That function will be run in async coroutine, and there will be already running event loop.

Like this: async -> sync -> async.

It can be easly scheduled in event loop by asyncio.create_task.

But can i somehow await it in that sync function?

Thank you.

Anton Vahmin
  • 339
  • 1
  • 4
  • 15
  • 1
    You cannot do so, at least not in the same event loop. If you could await the async function, your sync function would block the event loop. Which means it wouldn't be able to execute the inner async function, and... you have a deadlock. – user4815162342 Jul 24 '19 at 20:18
  • [This link](https://stackoverflow.com/a/56525798/1113207) contains an answer to your question. – Mikhail Gerasimov Jul 25 '19 at 03:38

0 Answers0