471,348 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

SOAPpy port reuse

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
4 2685
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
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
>>>>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
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.

Similar topics

reply views Thread by Vivek | last post: by
reply views Thread by Harry George | last post: by
reply views Thread by elsarfhem | last post: by
reply views Thread by Sameer Deshpande | last post: by
reply views Thread by benboals | last post: by
reply views Thread by linuxprog | last post: by
reply views Thread by sberry | last post: by
reply views Thread by pion | last post: by
1 post views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.