2

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.

dsolimano
  • 8,870
  • 3
  • 48
  • 63
Jonathan Livni
  • 101,334
  • 104
  • 266
  • 359

1 Answers1

2

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.

C2H5OH
  • 5,452
  • 2
  • 27
  • 39
  • 1
    Which is expected, given the quality of the Python documentation. See [Are urllib2 and httplib thread safe?](http://stackoverflow.com/questions/5825151/) – Piotr Dobrogost Apr 26 '12 at 16:27