[英]Does asyncio support running a subprocess from a non-main thread?
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. 即它表示
asyncio supports running subprocesses from different threads
An event loop must run in the main thread
,并且An event loop must run in the main thread
在同一部分An event loop must run in the main thread
中An event loop must run in the main thread
。
How is it even possible to run subprocess from different threads if event loop must run in the main thread? 如果事件循环必须在主线程中运行,那么甚至可以从不同的线程运行子进程?
Documentation says: 文件说:
asyncio.get_child_watcher()
at the start of the program. asyncio.get_child_watcher()
。 After that you may create subprocess from non-main thread. 之后,您可以从非主线程创建子进程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.