Skip to content

Instantly share code, notes, and snippets.

@beledouxdenis
Created January 3, 2020 15:27
Show Gist options
  • Save beledouxdenis/5abf3aad265758abd3fb900f0c2630ad to your computer and use it in GitHub Desktop.
Save beledouxdenis/5abf3aad265758abd3fb900f0c2630ad to your computer and use it in GitHub Desktop.
Multi-threaded requests flood to HTTP server
#!/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