[Twisted-web] Shutting down a xmlrpc server with an xmlrpc call

Matt Goodall matt at pollenation.net
Mon Jun 20 08:17:19 MDT 2005


Rasjid Wilcox wrote:
> Hi,
> 
> I am new to twisted-web, so my apologies if this is obvious.  I am happy to be 
> pointed at the appropriate documentation.
> 
> I am writing an xmlrpc server, and would like to there to be an xmlrpc call to 
> shutdown the server gracefully.
> 
> Ideally upon the call being made, it would return a 'success' response to the 
> client, the reactor would stop taking any new requests, would finish any 
> existing ones, and then exit cleanly.
> 
> What I currently have is -
>     def xmlrpc_quit(self):
>         reactor.stop()
> 
> but then the caller gets:
> 
> 
>>>>import xmlrpclib
>>>>s = xmlrpclib.Server('http://localhost:7080/')
>>>>s.quit()
> 
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/lib/python2.3/xmlrpclib.py", line 1029, in __call__
>     return self.__send(self.__name, args)
>   File "/usr/lib/python2.3/xmlrpclib.py", line 1316, in __request
>     verbose=self.__verbose
>   File "/usr/lib/python2.3/xmlrpclib.py", line 1070, in request
>     headers
> xmlrpclib.ProtocolError: <ProtocolError for localhost:7080/: -1 >
> 
> All suggestions / hints would be greatly appreciated.

You probably just need to return *something* from xmlrpc_quit, i.e. an
empty string. Currently, xmlrpc_quit returns None which is not supported
in XML-RPC.

Cheers, Matt

-- 
     __
    /  \__     Matt Goodall, Pollenation Internet Ltd
    \__/  \    w: http://www.pollenation.net
  __/  \__/    e: matt at pollenation.net
 /  \__/  \    t: +44 (0)113 2252500
 \__/  \__/
 /  \          Any views expressed are my own and do not necessarily
 \__/          reflect the views of my employer.



More information about the Twisted-web mailing list