signal handling oddity

Justin Johnson justinjohnson at
Mon Jun 9 16:37:02 CEST 2003

Yeah, I was using twisted before for this server and it did handle
control-c correctly.  I was having problems getting authentication to
work though, so I ended up moving to SimpleXMLRPCServer and adding some
other code to get basic authentication to work.  I'm just not familiar
enough with twisted to know what to subclass/override, etc... to get
simple user/password authentication to work.

Would you be able to help me get this working?

Of course if twisted.cred is rewritten this month (like the comments on
the twisted list seem to indicate), my problems might be solved.  :-)

Thanks for the reply.

On 9 Jun 2003 14:22:15 -0000, "Moshe Zadka" <m at> said:
> On Mon, 09 Jun 2003, "Justin Johnson" <justinjohnson at> wrote:
> > I tried adding code to
> > handle SIGINT (below).  What happens now is, I control-c and nothing
> > happens, but when the next xmlrpc request comes through, the service
> > exits, running stopService.  So the control-c is caught, but only when
> > the next request comes through.  Anyone know why this is?
> You didn't bother to mention which platform it is. In any case, the
> problem is due to some interaction between what Python does to make
> sure your signal handling is safe and how the OS works. I can never
> remember the exact reason, but it boils down to signals not interrupting
> blocking system calls. The solution, of course, is not to block. If
> SimeplXMLRPCServer uses what I think it does (an accept() call)
> then there is no easy way to solve it.
> At the risk of annoying lots of people here, I would suggest using
> the Twisted XML-RPC server support. Twisted on Windows (where IIRC
> this problem manifests itself) will run select() for at most 5-second
> delays, so a C-c would have at most 5 second delays. If even that
> is too much,
> def foo():
>     reactor.callLater(1, foo)
> foo()
> should make sure it caps at 1 second, at the cost of a slight performance
> penalty.
> Further reading:
> Using XML-RPC:
> Setting up the web server:
> -- 
> Moshe Zadka --
> Buffy: I don't like you hanging out with someone that... short.
> Riley: Yeah, a lot of young people nowadays are experimenting with
> shortness.
> Agile Programming Language --
> -- 

More information about the Python-list mailing list