[PEAK] terminating PEAK application

Yaroslav Samchuk yarcat at ank-sia.com
Sun Aug 1 17:34:58 EDT 2004


On Sun, Aug 01, 2004 at 11:58:35AM -0400, Phillip J. Eby wrote:
> At 03:23 PM 8/1/04 +0300, Yaroslav Samchuk wrote:
> >but none of these implementations help me to stop the service :( Could
> >you, please, tell me, what I'm doing wrong? why application could not be
> >stopped event if I'm trying to stop mainLoop?
> >
> >Actually, both of the implementations works, if the program is not
> >running as a service.
> 
> Hm.  That suggests that it's something to do with how services run, rather 
> than a PEAK issue.  But you didn't mention whether the log output shows 
> that it receives the signal or executes the _mainLoop.exitWith().  You 
> might want to add some logging to make sure that the routines you're using 
> to stop the main loop are actually getting called.

I've solved the problem - just wrote a C module, which contained `_raise`
(man 2 raise) routine. It's strange, that there is no implementation of
`raise` function for Win32 in the python. Python has a `kill` and `alarm`
implementations for the unix, but nothing is implemented for win32.

So, using my module, I'm raising SIGINT and it works (default PEAK's
sig handler just terminates main loop and it's what I want). Oh! You
have to disable SIGBREAK handling, if writing Win32 service :) or you
will have your service stoped after current user had logged off. It
seems, that on user's logout, windows sends SIGBREAK to all
apllications.

About executing of the _mainLoop.exitWith I can tell, that I have a
strong feeling, that it works only if fired inside PEAK application's loop.
For example, if I handle a TCP connection and I'm firing _mainLoop.exitWith(),
while handling the connection, main loop is terminating, but when service is
signaled to terminate, `exit with` is fired outside of the PEAK application
loop and is not working.

Actually, I was trying to fire reactor.callLater(mainLoop.exitWith, 0)
from my `stop_BBS` routine, but it also didn't work if called from
service's termination method :( I don't know why - I was really short of
time and my implementation of signals' raiser had helped, so I had stoped
researches in any other direction.

--
Best wishes,
Yaroslav




More information about the PEAK mailing list