mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
30 lines
635 B
Python
30 lines
635 B
Python
import requests
|
|
import random
|
|
import threading
|
|
import logging
|
|
import sys
|
|
|
|
pyapps = ['http://pyapp:5000/']
|
|
concurrency = 5
|
|
|
|
def do_requests():
|
|
while True:
|
|
try:
|
|
requests.get(random.choice(pyapps))
|
|
except:
|
|
logging.error("Error doing request", exc_info=sys.exc_info())
|
|
logging.info("Did request")
|
|
|
|
def main():
|
|
logging.info("Starting %d thread", concurrency)
|
|
threads = [threading.Thread(target=do_requests) for i in range(concurrency)]
|
|
for thread in threads:
|
|
thread.start()
|
|
for thread in threads:
|
|
thread.join()
|
|
logging.info("Exiting")
|
|
|
|
if __name__ == "__main__":
|
|
logging.basicConfig()
|
|
main()
|