Closed grodtron closed 8 years ago
Quick guess: multiprocessing.Process
uses fork()
, and I think sockets tend not to survive forks unless you do special stuff. So try only creating your sockets inside/after the fork?
Hi @djc actually the socket is only created inside/after the fork (inside the multiprocessing.Process
"thread")
Possibly this is related to the same root cause as #4 ?
Yeah, you should probably talk to the nanomsg community first about what you're trying to do.
Closing this, as it seems to be an upstream nanomsg issue.
Problem
When I have two
nnpy.Socket
s, aREQ
socket in the main thread, and aSUB
socket created later in amultiprocessing.Process
, theSUB
socket never receives anything. This problem does not occur for:SUB
socket in amultiprocessing.Process
.SUB
andREQ
sockets both in the main thread.SUB
socket in athreading.Thread
andREQ
socket in the main thread (but I have no choice but to usemultiprocessing.Process
for other reasons)Minimal Example
main.py
child.py
This code works if we either remove the
'start'
'Starting!'
request/response, or runrun_sub
in the main thread or athreading.Thread
instead of in amultiprocessing.Process
.Here are test cases with more print statements that show the cases where this works and does not work.
The problem is definitely on the receiving end, as the
SUB
/PUB
socket can be subscribed to and receives the messages in other programs.