[issue30945] loop.create_server does not detect if the interface is IPv6 enabled
New submission from Cecile Tonglet: The IPv6 detection in asyncio.base_events.create_server only detect if IPv6 is available instead of checking if the interface can actually support it. I noticed that by using Python in a Docker container (example code to reproduce in attachment): docker run -it --rm -v /tmp/test_ipv6.py:/src/test_ipv6.py python:3.6 python /src/test_ipv6.py Will result in: Traceback (most recent call last): File "/usr/local/lib/python3.6/asyncio/base_events.py", line 1043, in create_server sock.bind(sa) OSError: [Errno 99] Cannot assign requested address During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/src/test_ipv6.py", line 11, in server = loop.run_until_complete(server_creation) File "/usr/local/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete return future.result() File "/usr/local/lib/python3.6/asyncio/base_events.py", line 1047, in create_server % (sa, err.strerror.lower())) OSError: [Errno 99] error while attempting to bind on address ('::1', 27015, 0, 0): cannot assign requested address By default Docker containers have only IPv4 enabled: 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 38: eth0@if39: mtu 1500 qdisc noqueue state UP group default link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff inet 172.17.0.2/16 scope global eth0 valid_lft forever preferred_lft forever I believe this detection mechanism should rely on the interface requested. I found this on the web for Python 2 that manage to get the info per interface: https://pastebin.com/VEnhF1Ht but it's using an external library. However if you change the hostname to 127.0.0.1 it works normally. -- components: asyncio files: test_ipv6.py messages: 298474 nosy: cecton, yselivanov priority: normal severity: normal status: open title: loop.create_server does not detect if the interface is IPv6 enabled type: behavior versions: Python 3.4, Python 3.5, Python 3.6 Added file: http://bugs.python.org/file47019/test_ipv6.py ___ Python tracker <http://bugs.python.org/issue30945> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30945] loop.create_server does not detect if the interface is IPv6 enabled
Cecile Tonglet added the comment: Sure! It seems to work, the process returns an exit code of 0 and I see no traceback but the message is still displayed in the terminal. (Also I did something weird because your patch applies on branch master and I ran it with Python 3.6... I suppose it shouldn't be a problem) [0] [11:54:13] /tmp > d run -it --rm -v /tmp:/tmp:ro -v ~/repos/cpython/Lib/asyncio:/usr/local/lib/python3.6/asyncio:ro python:3.6 python /tmp/test_ipv6.py error while attempting to bind on address ('::1', 27015, 0, 0): cannot assign requested address [0] [11:54:19] /tmp > d run -it --rm -v /tmp:/tmp:ro python:3.6 python /tmp/test_ipv6.py Traceback (most recent call last): File "/usr/local/lib/python3.6/asyncio/base_events.py", line 1043, in create_server sock.bind(sa) OSError: [Errno 99] Cannot assign requested address During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/tmp/test_ipv6.py", line 11, in server = loop.run_until_complete(server_creation) File "/usr/local/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete return future.result() File "/usr/local/lib/python3.6/asyncio/base_events.py", line 1047, in create_server % (sa, err.strerror.lower())) OSError: [Errno 99] error while attempting to bind on address ('::1', 27015, 0, 0): cannot assign requested address [1] [11:54:52] /tmp > -- ___ Python tracker <http://bugs.python.org/issue30945> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30945] loop.create_server does not detect if the interface is IPv6 enabled
Cecile Tonglet added the comment: I see that the patch hasn't been applied to master on GitHub. Is there anything else expected from me on this ticket? -- ___ Python tracker <https://bugs.python.org/issue30945> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com