2023-06-08 02:01:38 -04:00
|
|
|
# Test basic behaviour of asyncio.start_server()
|
2021-06-25 02:53:20 -04:00
|
|
|
|
|
|
|
try:
|
2023-06-08 02:01:38 -04:00
|
|
|
import asyncio
|
2021-06-25 02:53:20 -04:00
|
|
|
except ImportError:
|
2023-06-08 02:01:38 -04:00
|
|
|
print("SKIP")
|
|
|
|
raise SystemExit
|
2021-06-25 02:53:20 -04:00
|
|
|
|
|
|
|
|
|
|
|
async def test():
|
|
|
|
# Test creating 2 servers using the same address
|
|
|
|
print("create server1")
|
|
|
|
server1 = await asyncio.start_server(None, "0.0.0.0", 8000)
|
|
|
|
try:
|
|
|
|
print("create server2")
|
|
|
|
await asyncio.start_server(None, "0.0.0.0", 8000)
|
|
|
|
except OSError as er:
|
|
|
|
print("OSError")
|
|
|
|
|
|
|
|
# Wait for server to close.
|
|
|
|
async with server1:
|
|
|
|
print("sleep")
|
|
|
|
await asyncio.sleep(0)
|
|
|
|
|
|
|
|
print("done")
|
|
|
|
|
|
|
|
|
|
|
|
asyncio.run(test())
|