xmlrpc: problems with socket handling, close, shutdown of server, TIME_WAIT, ...

dieter dieter at handshake.de
Wed May 7 02:43:16 EDT 2014


thomas.lehmann.private at googlemail.com writes:

> ...
> taking the xml-rpc derived from standard example is working - basically - but with following scenario I do not understand the problem. Maybe you can help:
>
>  - one Unittest that does create the xmlrpc server in a thread
>    in "setUp" and shutdown of it in tearDown.
>    The xml-rcp server does store/load a value for a key.
>    (It's for testing/learning purpose)
>
> Problem(s):
>
>  - If I run the test method twice (copy and paste and rename)
>    then I get a "error: [Errno 98] Address already in use"
>    (I assumend the tearDown would have closed all sockets)

For reliability reasons (their might be (communication) packets under way
that may arrive at the wrong partner), a port stays "in use"
for twice (I think) the maximal packet lifetime after its "shutdown".
This is a TCP (not a Python) property.
There is a TCP(socket) option to supress this.

For the details, consult the TCP specification.




More information about the Python-list mailing list