[zeromq-dev] Check if forwarder is running

Ronald Swain proj_symbian at live.com
Wed Mar 21 08:13:13 CET 2012


Thanks for the reply, so do you mean that process kill cant be handled in python for windows, i tried using atexit and thats not working too. :-(

Now pyzmq specific question, what i am thinking of is i want my client to start the forwarder, if not started, and then the next connecting client just check if its started or not and then use that for communication.

So i am thinking of implementing the forwarder device as a singleton , is that the correct method or there is something in zmq which will help me to solve this problem.

> Date: Tue, 20 Mar 2012 21:39:13 -0700
> From: pelletier.michel at gmail.com
> To: zeromq-dev at lists.zeromq.org
> Subject: Re: [zeromq-dev] Check if forwarder is running
> 
> Signals are a unix concept.  Not that I would know, but I'm guessing
> there is some funkyness with the way python signals work on Windows as
> this blog post implies:
> 
> http://danielkaes.wordpress.com/2009/06/04/how-to-catch-kill-events-with-python/
> 
> "In the Linux world catching “kill events” would be a simple task, to
> shut down another program a process just has to send a SIGTERM signal
> which can be caught be Python easily using the signal module which
> comes with every Python installation. However, on Windows things are a
> little bit harder, because the operating system never produces SIGTERM
> (and SIGILL) events according to the signal.h documentation from
> MSDN."
> 
> Remove all the zmq code entirely from your example and reproduce the
> most minimal signal handler that prints on signal and I bet it still
> won't work.
> 
> You might want to look into the atexit module:
> 
> http://docs.python.org/library/atexit.html
> 
> 
> On Tue, Mar 20, 2012 at 9:14 PM, Ronald Swain <proj_symbian at live.com> wrote:
> > Hmmm i tried using your code but , its not working too. :-(
> >
> > Regarding PyZMQ version i am using pyzmq 2.1.11 which have same version of
> > libzmq i guess. And i am on a 64 bit windows machine.
> >
> > ________________________________
> > Date: Tue, 20 Mar 2012 12:44:57 -0500
> >
> > From: cornelius.toole at gmail.com
> > To: zeromq-dev at lists.zeromq.org
> > Subject: Re: [zeromq-dev] Check if forwarder is running
> >
> > I forked and edited the gist with my changes and comments. I'm not really
> > sure what's wrong, but you may be having a scope
> > problem: https://gist.github.com/2138347
> > http://stackoverflow.com/questions/423379/using-global-variables-in-a-function-other-than-the-one-that-created-them
> >
> >
> > incoming, outgoing and context are visible within
> > the termSignalHandler function, you need to add a global statement at the
> > beginning of your function definitions, like so:global incoming, outgoing,
> > context
> >
> > What version of pyzmq, libzmq are you using?
> >
> >
> > --
> > Cornelius Toole
> > Sent with Sparrow
> >
> > On Tuesday, March 20, 2012 at 12:13 PM, Ronald Swain wrote:
> >
> > Hello Cornelius ,
> >
> > Thanks again and it will work for sure.
> >
> > Next and probably last question is why my sockets are not cleaned up in the
> > forwarder, i try something like https://gist.github.com/2132163 but the
> > handler is never fired.
> >
> > just to inform you i kill the python interpreter to close the forwarder.
> >
> >
> >
> > ________________________________
> > Date: Tue, 20 Mar 2012 10:09:04 -0500
> > From: cornelius.toole at gmail.com
> > To: zeromq-dev at lists.zeromq.org
> > Subject: Re: [zeromq-dev] Check if forwarder is running
> >
> > Ronald,
> >
> > Do i need to close forwarder again and than start after each message sent by
> > the publisher, or can i do something like i can start the forwarder first
> > and next publisher check if the forwarder is running than just leverage the
> > forwarder to send some messages to the subscriber.
> >
> > No you just leave the forwarder running. That's the magic of using a
> > forwarder with pub-sub sockets. But you should probably change how the
> > forwarder device is configured. The way I use the forwarder is to have it
> > bind both the incoming and outgoing sockets and then have the producers and
> > consumers connect to the forwarder; that way once the forwarder is running,
> > producer and consumer processes can start and stop without crashing the
> > other.
> > See: https://gist.github.com/2136666#comments
> >
> >
> > --
> > Cornelius Toole
> > Sent with Sparrow
> >
> > On Tuesday, March 20, 2012 at 4:35 AM, Symbian Projects wrote:
> >
> > Hello All,
> >
> > In one of my past threads i got the zmq device forwarder working, now my
> > exact use case is like i have arbitrary no of publishers and subscribers.
> >
> > First i start the ZMQ forwarder device, than i am starting the subscribers
> > and than a single publisher to send the message.
> >
> > My objective is there are no of publishers who  should be able to send
> > messages to the connected subscribers, now how this can happen with a
> > FORWARDER.
> >
> > Do i need to close forwarder again and than start after each message sent by
> > the publisher, or can i do something like i can start the forwarder first
> > and next publisher check if the forwarder is running than just leverage the
> > forwarder to send some messages to the subscriber.
> >
> > I hope my question is clear.
> >
> > Thanks a Lot for reply.
> > Ronald
> >
> >
> > _______________________________________________
> > zeromq-dev mailing list
> > zeromq-dev at lists.zeromq.org
> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> >
> >
> >
> > _______________________________________________ zeromq-dev mailing list
> > zeromq-dev at lists.zeromq.org
> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> > _______________________________________________
> > zeromq-dev mailing list
> > zeromq-dev at lists.zeromq.org
> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> >
> >
> >
> > _______________________________________________ zeromq-dev mailing list
> > zeromq-dev at lists.zeromq.org
> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> >
> > _______________________________________________
> > zeromq-dev mailing list
> > zeromq-dev at lists.zeromq.org
> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
> >
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.zeromq.org/pipermail/zeromq-dev/attachments/20120321/cf24b522/attachment.htm 


More information about the zeromq-dev mailing list