Discussion:
[Pyro] Question: how to exit a Pyro server?
Gardner Pomper
2006-04-11 12:57:11 UTC
Permalink
Hi,

I have a really dumb question... what breaks a pyro server out of the
daemon.requestloop() call? Can I send something from a client app to cause
the server to exit? I don't want to have to manually kill off all my
servers.

Thanks,

- Gardner
Seth Remington
2006-04-14 01:48:05 UTC
Permalink
Well, the Daemon has a shutdown() method that you could explicitly call. So if you passed your server object a reference to the daemon that it was connected to you could publish a remote method to invoke daemon.shutdown(). I haven't actually tried that myself though.

-Seth
Post by Gardner Pomper
Hi,
I have a really dumb question... what breaks a pyro server out of the
daemon.requestloop() call? Can I send something from a client app to cause
the server to exit? I don't want to have to manually kill off all my
servers.
Thanks,
- Gardner
--
Seth Remington
SaberLogic LLC
661 Suite B Weber Drive Wadsworth, Ohio 44281
***@saberlogic.com Ph: 330.335.6442 Fax: 330.336.8559
Humphreys, Brett
2006-04-14 11:03:06 UTC
Permalink
So I had a similar problem, I get an asynchronous call to a quit method,
and from that quit method I want to be able to stop my pyro daemon.
Here's what I had to do.

The requestLoop method takes four optional parameters:
- condition -- callback method
- timeout -- integer timeout
- others -- list of file descriptors

The condition variable tells the daemon whether or not it should
continue to run. However it only checks this after each pyro request
was handled. The timeout is the amount of time (in seconds iirc), the
select loop should wait until checking the condition method. The others
list is a list of other file descriptors the select loop should wait on.


I created an os.pipe tuple, and added the read end of the pipe to the
'others' list. When I want the daemon to stop, I first set an internal
variable such that my condition method will return false. I then write
1 byte on the write end of the aforementioned pipe. This forces the
select loop out immediately, and then checks my callback which now is
returning false, and forces requestLoop() to exit cleanly. The timeout
I decided not to use because it uses needless cpu, and then there would
always be a delay after I called stop on the daemon and when the
requestLoop() method actually returns.

This was all done in a subclassed Pyro.core.Daemon class, but there are
multiple ways to skin this cat.

-Brett

-----Original Message-----
From: pyro-core-***@lists.sourceforge.net
[mailto:pyro-core-***@lists.sourceforge.net] On Behalf Of Seth
Remington
Sent: Thursday, April 13, 2006 11:47 PM
To: pyro-***@lists.sourceforge.net
Subject: [Pyro] Re: Question: how to exit a Pyro server?


Well, the Daemon has a shutdown() method that you could explicitly call.
So if you passed your server object a reference to the daemon that it
was connected to you could publish a remote method to invoke
daemon.shutdown(). I haven't actually tried that myself though.

-Seth
Post by Gardner Pomper
Hi,
I have a really dumb question... what breaks a pyro server out of the
daemon.requestloop() call? Can I send something from a client app to
cause the server to exit? I don't want to have to manually kill off
all my servers.
Thanks,
- Gardner
--
Seth Remington
SaberLogic LLC
661 Suite B Weber Drive Wadsworth, Ohio 44281
***@saberlogic.com Ph: 330.335.6442 Fax: 330.336.8559




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language that extends applications into web and mobile media. Attend the
live webcast and join the prime developer group breaking into this new
coding territory!
http://sel.as-us.falkag.net/sel?cmd=k&kid0944&bid$1720&dat1642
Continue reading on narkive:
Search results for '[Pyro] Question: how to exit a Pyro server?' (Questions and Answers)
10
replies
Runescape - How Can I Trade/Transfer/Drop Items To Another Account?
started 2010-09-25 14:42:07 UTC
video & online games
Loading...