Open rth opened 1 year ago
FWIW, similar question when using a multiprocessing.Queue
for synchronization with the created process. Submitted messages to the Queue inside the process are never received outside.
So I ended up using just plain multiprocessing with a basic implementation,
from multiprocessing import Process
import uvloop
def _run_in_loop(func, args):
loop = uvloop.new_event_loop()
loop.run_until_complete(func(*args))
def run_coroutine_in_process(func, *args) -> Process:
process = Process(target=_run_in_loop, args=(func, args))
process.start()
return process
which appears to work with both multiprocessing.Value and multiprocessing.Queue with Python 3.11 (on Linux)
If I try to use
multiprocessing.Value
for synchronization withaiomultiprocess.Process
and uvloop even loop, the process gets silently terminated with no error messages.Example
Expected behavior
In this example, I would expect the
ValueError
to be raised and displayed. This is indeed what happens if thesignal.value
line is removed.Current behavior
Currently an assertion error is raised,
which means that the process is either never started or is terminated before reaching the line that raises the
ValueError
.Am I doing something wrong?
Versions