try ... except ... not working properly when using asyncio for heavy concurrency #107285
Labels
pending
The issue will be closed if no feedback is provided
topic-asyncio
type-bug
An unexpected behavior, bug, or error
Bug report
When I use asyncio to write a port scanner, I connect the socket in the try statement, and use 'asyncio.timeout' and 'asyncio.wait_for' for timeout processing. When the concurrency reaches more than 5000, this problem occurs.
The main part of the code is as follows:
This code is called like this 'Scan(['192.168.22.2', '192.168.179.30'], [1-65535]).scan_port() ', 'targets' are two LAN IPs, 'ports' are all ports 1-65535.
When using asyncio.timeout, the output is:
It can be seen that the connection to port 22 is successful, no exception is triggered, but the else statement is not executed.
When using asyncio.wait_for, also have this problem, just the port is different.
I can avoid this problem by adjusting the number of workers and the value of timeout, but this should be a bug.
I'm guessing the problem might be related to this. #96037
Your environment
This problem occurs on both Ubuntu and MacOS, not tested for windows.
Ubuntu:
MacOS:
The text was updated successfully, but these errors were encountered: