SOAPpy port reuse

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sun Nov 18 13:16:29 EST 2007


En Sun, 18 Nov 2007 11:17:42 -0300, Maurice LING <mauriceling at acm.org>  
escribi�:

> Diez B. Roggisch wrote:
>> Maurice LING schrieb:

>>> My question is: How can I shutdown this server and reuse port 35021
>>> when my functionlist changes?
>>
>> Shutting down gracefully might speed up things I guess.
>>
> I am under the impression that SOAPpy.SOAPServer.serve_forever() is an
> "endless" loop. I had been suggested to see if there is a method of
> SOAPpy.SOAPServer (which I can call through a wrapper function in
> functionlist) that can enable me to gracefully shutdown the server.

serve_forever is inherited from SocketServer.BaseServer and it's just an  
infinite loop calling self.handle_request() over and over.
You have to break out of the loop somehow and call self.server_close().  
Something like this (untested):

     def serve_forever(self):
         while not self.some_flag_to_indicate_it_has_to_stop:
             self.handle_request()
         self.server_close()

-- 
Gabriel Genellina




More information about the Python-list mailing list