Skip to content

Instantly share code, notes, and snippets.

@libbkmz
Created June 4, 2019 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save libbkmz/b580215db3c005d81c7af0e358cd5354 to your computer and use it in GitHub Desktop.
Save libbkmz/b580215db3c005d81c7af0e358cd5354 to your computer and use it in GitHub Desktop.
import requests as req
import concurrent.futures as cf
import string
import random
WORKERS = 32
random_str = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(128))
def worker():
while True:
_ = req.put(
"http://127.0.0.1:9999/not_found_url",
data=random_str,
headers={
"Content-Type": "application/json",
})
if __name__ == "__main__":
executor = cf.ThreadPoolExecutor(max_workers=WORKERS)
fs = []
for _ in range(WORKERS):
fs.append(
executor.submit(worker)
)
for f in cf.as_completed(fs):
print (f.result())
from flask import Flask, request
app = Flask(__name__)
@app.route("/", methods=["PUT"])
def hello():
_ = (request.data)
return "Hello World!"
if __name__ == "__main__":
app.run(host='127.0.0.1', port=9999, debug=False, threaded=True)
@libbkmz
Copy link
Author

libbkmz commented Jun 4, 2019

python2:
pip install flask requests futures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment