Closed ghost closed 6 years ago
See https://github.com/kaniini/antissh/blob/465b43f6953766a7ede16b41198fc35ea16b422b/antissh.py#L228
Right now, it uses the following code:
async def check_with_credentials_group(ip, target_ip, target_port, credentials_group=DEFAULT_CREDENTIALS): futures = [check_with_credentials(ip, target_ip, target_port, c[0], c[1]) for c in credentials_group] results = await asyncio.gather(*futures) return True in results
This unnecessarily waits for results to be populated before performing the check True in results. A better approach would be something like:
results
True in results
async def check_with_credentials_group(ip, target_ip, target_port, credentials_group=DEFAULT_CREDENTIALS): futures = asyncio.as_completed(map(lambda c: check_with_credentials(ip, target_ip, target_port, c[0], c[1]), credentials_group)) for future in futures: result = await future if result: return True return False
See https://github.com/kaniini/antissh/blob/465b43f6953766a7ede16b41198fc35ea16b422b/antissh.py#L228
Right now, it uses the following code:
This unnecessarily waits for
results
to be populated before performing the checkTrue in results
. A better approach would be something like: