Created
January 3, 2020 15:27
-
-
Save beledouxdenis/5abf3aad265758abd3fb900f0c2630ad to your computer and use it in GitHub Desktop.
Multi-threaded requests flood to HTTP server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import requests | |
import sys | |
import threading | |
from urllib3.exceptions import InsecureRequestWarning | |
# Suppress only the single warning from urllib3 needed. | |
requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning) | |
def request(): | |
try: | |
r = requests.get('http://test_nginx', timeout=10, verify=False) | |
r.raise_for_status() | |
except Exception: | |
print('NOK') | |
threads = [] | |
for i in range(int(sys.argv[1])): | |
threads.append(threading.Thread(target=request)) | |
for thread in threads: | |
thread.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment