Reputation: 107092
Is a multiprocessing.Connection
python object thread safe?
If it is, two threads could simultaneously use conn.recv()
and conn.send()
on the same connection, which could be useful for full-duplex communication.
Upvotes: 2
Views: 774
Reputation: 5602
It looks like it is not thread safe. Up to Python 3.2, multiprocessing.Connection
objects do not have any semaphore attached, nor does any of the library code that uses them.
Interestingly, in Python 3.3 the implementation has moved. But again, no locking primitive is beign used.
The documentation does not mention too much about the thread-safety of the multiprocessing
module. Which is a bit unexpected, given the quality of the Python documentation.
Upvotes: 2