Does asyncio support running a subprocess from a n

2019-05-10 16:41发布

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?

1条回答
何必那么认真
2楼-- · 2019-05-10 17:11

Documentation says:

  1. You should have running event loop in the main thread.
  2. In the main thread please call asyncio.get_child_watcher() at the start of the program.

After that you may create subprocess from non-main thread.

查看更多
登录 后发表回答