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

Add threading to socket check #257

Merged
merged 3 commits into from
Nov 9, 2024
Merged

Add threading to socket check #257

merged 3 commits into from
Nov 9, 2024

Conversation

dsgnr
Copy link
Owner

@dsgnr dsgnr commented Nov 9, 2024

Adds threading to query_ipv4 method. Uses default worker value (CPU count). This will improve performance where there are more than one port that does not response, thus reaching the timeout limit.

Before:

  >>> import os;os.cpu_count()
  12
  >>> from timeit import timeit
  >>> r = 'import requests; requests.post("http://localhost:8000/api/query", json={"host": "google.com", "ports": [21, 22, 23, 25, 53, 80, 110, 443, 465, 8080, 8443, 9090]}).json()'
  >>> timeit(r, number=1)
  10.265458297042642

After:

  >>> import os;os.cpu_count()
  12
  >>> from timeit import timeit
  >>> r = 'import requests; requests.post("http://localhost:8000/api/query", json={"host": "google.com", "ports": [21, 22, 23, 25, 53, 80, 110, 443, 465, 8080, 8443, 9090]}).json()'
  >>> timeit(r, number=1)
  1.041649337974377 

@dsgnr dsgnr merged commit d442da9 into devel Nov 9, 2024
3 checks passed
@dsgnr dsgnr deleted the concurrency branch November 9, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant