Skip to content

Using multiprocessing.Value silently terminates the Process  #179

Description

@rth

If I try to use multiprocessing.Value for synchronization with aiomultiprocess.Process and uvloop even loop, the process gets silently terminated with no error messages.

Example

from aiomultiprocess import Process
import uvloop
from time import sleep
from multiprocessing import Value

async def func(signal):
    signal.value
    raise ValueError


if __name__ == '__main__':
    signal = Value('i', 0)
    proc = Process(                               
        target=func,                    
        loop_initializer=uvloop.new_event_loop,   
        args=(signal,),                      
    )                                             
    proc.start()                                  
    sleep(1)                                      
    assert proc.is_alive()

Expected behavior

In this example, I would expect the ValueError to be raised and displayed. This is indeed what happens if the signal.value line is removed.

Current behavior

Currently an assertion error is raised,

    assert proc.is_alive()
AssertionError

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

Python 3.10.8 on Ubuntu Linux
aiomultiprocess         0.9.0
uvloop                  0.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions