[Python-checkins] CVS: python/dist/src/Lib/test test_asynchat.py,1.3,1.4

Thomas Wouters thomas@xs4all.net
Sun, 15 Apr 2001 17:41:57 +0200

On Sat, Apr 14, 2001 at 05:42:16PM -0700, Guido van Rossum wrote:

> Modified Files:
> 	test_asynchat.py 
> Log Message:
> Set the SO_REUSEADDR socket option in the server thread -- this seems
> needed on some platforms (e.g. Solaris 8) when the test is run twice
> in quick succession.

>       def run(self):
>           sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> +         sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
>           sock.bind((HOST, PORT))
>           sock.listen(1)

I think this has to be protected by a hasattr() or try: block, because
SO_REUSEADDR isn't always available. From socketmodule.c:

        insint(d, "SO_REUSEADDR", SO_REUSEADDR);

Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!