[Python-Dev] test_multiprocessing:test_listener_client flakiness

Bill Janssen janssen at parc.com
Thu Jun 19 19:06:22 CEST 2008


This is a common problem.  Binding to '127.0.0.1' will bind to *only*
that address; binding to "" will bind to *all* addresses the machine
is known by.  If the client uses a different way of getting the
address than the literal '127.0.0.1' (like a call to getfqdn(), which
has pretty indeterminate results), you should use the "" form when
calling bind.

If you know you want to talk to '127.0.0.1', just use the tuple
('127.0.0.1', <PORT>) as the address.

Bill


> > Well, on my win2k machine getfqdn('127.0.0.1') returns the actual name
> > of the machine. This is the name that was stored in server.address.
> > Hence my patch that simply remove the call to getfqdn.
> 
> +1 to ditching getfqdn, following patch fixes the issue on my buildbot server:
> 
> Index: connection.py
> ===================================================================
> --- connection.py       (revision 64369)
> +++ connection.py       (working copy)
> @@ -215,10 +215,7 @@
>          self._socket = socket.socket(getattr(socket, family))
>          self._socket.bind(address)
>          self._socket.listen(backlog)
> -        address = self._socket.getsockname()
> -        if type(address) is tuple:
> -            address = (socket.getfqdn(address[0]),) + address[1:]
> -        self._address = address
> +        self._address = self._socket.getsockname()
>          self._family = family
>          self._last_accepted = None
> 
> 
> 
>         Trent.
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/janssen%40parc.com



More information about the Python-Dev mailing list