Message405530
To create a new server with `loop.create_server` that listens on all interfaces and a random port, I'd expect passing in `host=""`, `port=0` to work (per the documentation). However, as written this results in 2 different ports being used - one for ipv4 and one for ipv6. Instead I'd expect a single random port be determined once, and reused for all other interfaces.
Running the example test code (attached) results in:
```
$ python test.py
listening on 0.0.0.0:38023
listening on :::40899
Traceback (most recent call last):
File "/home/jcristharif/Code/distributed/test.py", line 36, in <module>
asyncio.run(main())
File "/home/jcristharif/miniconda3/envs/dask/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/home/jcristharif/miniconda3/envs/dask/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/home/jcristharif/Code/distributed/test.py", line 30, in main
assert len(ports) == 1, "Only 1 port expected!"
AssertionError: Only 1 port expected!
```
This behavior can be worked around by manually handling `port=0` outside of asyncio, but as it stands naive use can result in accidentally listening on multiple ports. |
|
Date |
User |
Action |
Args |
2021-11-02 18:32:35 | jcristharif | set | recipients:
+ jcristharif, asvetlov, yselivanov |
2021-11-02 18:32:35 | jcristharif | set | messageid: <1635877955.05.0.115164279782.issue45693@roundup.psfhosted.org> |
2021-11-02 18:32:35 | jcristharif | link | issue45693 messages |
2021-11-02 18:32:34 | jcristharif | create | |
|