Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_ipaddr_info monkey_patch breaks UDP #1016

Closed
jordens opened this issue May 28, 2018 · 3 comments
Closed

_ipaddr_info monkey_patch breaks UDP #1016

jordens opened this issue May 28, 2018 · 3 comments
Assignees

Comments

@jordens
Copy link
Member

jordens commented May 28, 2018

The monkey patch from #506 (1c32d4f) breaks UDP.
This in turn breaks pc_rpc device controllers that use UDP.

# python 3.5.3
import asyncio
import artiq.monkey_patches

loop = asyncio.get_event_loop()
loop.run_until_complete(loop.create_datagram_endpoint(
                object, remote_addr=("127.0.0.1", 4000)))
Traceback (most recent call last):
  File "test_monkey.py", line 6, in <module>
    object, remote_addr=("127.0.0.1", 4000)))
  File "/home/rj/src/conda/envs/py35/lib/python3.5/asyncio/base_events.py", line 466, in run_until_complete
    return future.result()
  File "/home/rj/src/conda/envs/py35/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/home/rj/src/conda/envs/py35/lib/python3.5/asyncio/tasks.py", line 241, in _step
    result = coro.throw(exc)
  File "/home/rj/src/conda/envs/py35/lib/python3.5/asyncio/base_events.py", line 932, in create_datagram_endpoint
    raise exceptions[0]
  File "/home/rj/src/conda/envs/py35/lib/python3.5/asyncio/base_events.py", line 919, in create_datagram_endpoint
    yield from self.sock_connect(sock, remote_address)
  File "/home/rj/src/conda/envs/py35/lib/python3.5/asyncio/selector_events.py", line 446, in sock_connect
    yield from resolved
  File "/home/rj/src/conda/envs/py35/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/home/rj/src/conda/envs/py35/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/home/rj/src/conda/envs/py35/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/home/rj/src/conda/envs/py35/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/rj/src/conda/envs/py35/lib/python3.5/socket.py", line 733, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -7] ai_socktype not supported
@sbourdeauducq
Copy link
Member

At some point the asyncio is calling:
loop.getaddrinfo("127.0.0.1", 4000, family=socket.AF_INET, type=socket.SOCK_STREAM, proto=17, flags=0)
which raises the exception and which I suspect is another Python bug that is exposed by the patch.

@sbourdeauducq
Copy link
Member

i.e. asyncio is asking for a stream UDP (proto=17) address, which is obviously not possible. Without the patch, the error is masked, as _ipaddr_info disregards the type/proto combination.

@jordens
Copy link
Member Author

jordens commented May 29, 2018

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants