Using SimpleXMLRPCServer in a Windows Service
Gabriel Genellina
gagsl-py at yahoo.com.ar
Fri Nov 24 22:49:23 EST 2006
At Thursday 23/11/2006 06:52, Rudy Schockaert wrote:
>After some Googling I found a post of someone who wanted to do exactly
>as what I want to do now.
>There is however a problem in his code that makes the service fails
>after the first connection. I slightly modified his code and now I can
>run the service longer before I run into trouble.
>I then tried making the SimpleXMLRPCServer multi-threaded, hoping the
>problem would disappear, but no avail.
>The code is as follows:
>The commented part in the while loop is from the original code.
The original (commented-out) code should be fine. You have to wait
for 2 events: the service stop signal, or an incoming connection.
Anyway, you always have to catch exceptions; override handle_error at least.
Another approach (not involving events) would be to set a (not so
big) timeout on the socket, and test for self.stop_requested on each iteration.
> server = ThreadedSimpleXMLRPCServer(("", 8080))
> object = OBJECT()
> server.register_instance(object)
> self.socket = server.socket
>
> while 1:
> #win32file.WSAEventSelect(server,
>self.hSockEvent,win32file.FD_ACCEPT)
> #rc =
>win32event.WaitForMultipleObjects((self.hWaitStop,self.hSockEvent), 0,
>win32event.INFINITE)
> #if rc == win32event.WAIT_OBJECT_0:
> # break
> #else:
> # server.handle_request()
> # win32file.WSAEventSelect(server,self.hSockEvent, 0)
> # #server.serve_forever() ## Works, but breaks the
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar
More information about the Python-list
mailing list