By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,235 Members | 1,008 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,235 IT Pros & Developers. It's quick & easy.

SOAPpy port reuse

P: n/a
Hi,

I have a problem:

1. Assuming that my application is a SOAP server that uses SOAPpy,
2. I am given port 35021 for use.

What I normally do (simply) is:

functionlist = [<some exposed functions>]
import SOAPpy
server = SOAPpy.SOAPServer((<some host>, 35021))
for func in functionlist: server.registerFunction(func)
server.serve_forever()

My question is: How can I shutdown this server and reuse port 35021 when
my functionlist changes?

Currently, after killing the python process which runs this SOAP server,
the port (35021 in this case) cannot be re-used, as though it is still
phantom-ly bounded to some process (which should have been killed).

Thanks in advance.

Cheers
maurice
Nov 18 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Maurice LING schrieb:
Hi,

I have a problem:

1. Assuming that my application is a SOAP server that uses SOAPpy,
2. I am given port 35021 for use.

What I normally do (simply) is:

functionlist = [<some exposed functions>]
import SOAPpy
server = SOAPpy.SOAPServer((<some host>, 35021))
for func in functionlist: server.registerFunction(func)
server.serve_forever()

My question is: How can I shutdown this server and reuse port 35021 when
my functionlist changes?

Currently, after killing the python process which runs this SOAP server,
the port (35021 in this case) cannot be re-used, as though it is still
phantom-ly bounded to some process (which should have been killed).
It shouldn't be that way. Either you still have some process lying
around hogging the port. Or the OS needs a while to re-enable the port
for allocation. That happened to me quite a few times.

Shutting down gracefully might speed up things I guess.

Diez
Nov 18 '07 #2

P: n/a
Diez B. Roggisch wrote:
Maurice LING schrieb:
>Hi,

I have a problem:

1. Assuming that my application is a SOAP server that uses SOAPpy,
2. I am given port 35021 for use.

What I normally do (simply) is:

functionlist = [<some exposed functions>]
import SOAPpy
server = SOAPpy.SOAPServer((<some host>, 35021))
for func in functionlist: server.registerFunction(func)
server.serve_forever()

My question is: How can I shutdown this server and reuse port 35021
when my functionlist changes?

Currently, after killing the python process which runs this SOAP
server, the port (35021 in this case) cannot be re-used, as though it
is still phantom-ly bounded to some process (which should have been
killed).

It shouldn't be that way. Either you still have some process lying
around hogging the port. Or the OS needs a while to re-enable the port
for allocation. That happened to me quite a few times.

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.

Any advice?

Thanks
Maurice
Nov 18 '07 #3

P: n/a
>>>>Maurice LING <ma*********@acm.org(ML) wrote:
>MLHi,
MLI have a problem:
>ML1. Assuming that my application is a SOAP server that uses SOAPpy,
ML2. I am given port 35021 for use.
>MLWhat I normally do (simply) is:
>MLfunctionlist = [<some exposed functions>]
MLimport SOAPpy
MLserver = SOAPpy.SOAPServer((<some host>, 35021))
MLfor func in functionlist: server.registerFunction(func)
MLserver.serve_forever()
>MLMy question is: How can I shutdown this server and reuse port 35021 when my
MLfunctionlist changes?
>MLCurrently, after killing the python process which runs this SOAP server,
MLthe port (35021 in this case) cannot be re-used, as though it is still
MLphantom-ly bounded to some process (which should have been killed).
This phenomenon is explained here:
http://hea-www.harvard.edu/~fine/Tech/addrinuse.html
or the Unix socket FAQ (http://www.faqs.org/faqs/unix-faq/socket/) 2.7

Normally the solution is to set the SO_REUSEADDR option in the socket (the
original one) before binding it:
s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR ,1)

However, SOAPPy does that already so it should work.
--
Piet van Oostrum <pi**@cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: pi**@vanoostrum.org
Nov 18 '07 #4

P: n/a
En Sun, 18 Nov 2007 11:17:42 -0300, Maurice LING <ma*********@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

Nov 18 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.