On Fri, Aug 30, 2013 at 11:50 AM, Townsend, Scott E. (GRC-RTM0)[Vantage Partners, LLC] <scott.e.towns...@nasa.gov> wrote:
MinRK noted that: > > You cannot continue to use zmq sockets after a fork - you have to > take care in your application that no sockets created before the fork will > be [not be] used by any calls in the child process. > > Thanks, that makes sense. But can anyone provide guidance in how to do > that? I'm quite new to zmq, but somewhat versed in Python multiprocessing. > I think there's only one zmq context in use by the main server, and in the > child process I context.term() as soon as I can. That did not fix the > issue (but then I don't know that it should). > > It's entirely possible that there are zmq messages in flight while the > multiprocessing fork is going on, so I can imagine that when a child 'wakes > up' it might think it should process a message that it shouldn't. Is it > possible to 'suspend' zmq while the fork is occurring so I can somehow have > the child cleanup things it shouldn't be using, and then the parent resumes > zmq processing? Or is there some way to mark the sockets such that they > aren't inherited by the child? Or something else I can try? > It depends on how your app works, and what events trigger zmq calls. Without knowing anything about your app or what tasks might access zmq from forked processes, one thing you can do is just make sure certain tasks only happen in the main process: if multiprocessing.current_process().name != 'MainProcess': # just skip this in forked process return zmq_api_call() -MinRK > _______________________________________________ > zeromq-dev mailing list > zeromq-dev@lists.zeromq.org > http://lists.zeromq.org/mailman/listinfo/zeromq-dev > >
_______________________________________________ zeromq-dev mailing list zeromq-dev@lists.zeromq.org http://lists.zeromq.org/mailman/listinfo/zeromq-dev