Reputation: 3981
I'm developing an application that mainly consists of services which are threads with custom run loops.
One of the services needs to spawn subprocesses and I don't really understand whether it's valid or not. Official documentation is ambiguous. Namely it says both asyncio supports running subprocesses from different threads
and An event loop must run in the main thread
in the same section.
How is it even possible to run subprocess from different threads if event loop must run in the main thread?
Upvotes: 7
Views: 1812
Reputation: 17376
Documentation says:
asyncio.get_child_watcher()
at the start of the program.After that you may create subprocess from non-main thread.
UPD
Starting from Python 3.8 asyncio has no limitations mentioned above.
Everything just works.
Upvotes: 12