Skip to content

Instantly share code, notes, and snippets.

@andygimma
Created March 24, 2016 23:14
Show Gist options
  • Save andygimma/ef6f6622a517268ae2b0 to your computer and use it in GitHub Desktop.
Save andygimma/ef6f6622a517268ae2b0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import urllib2
import thread
import sys
def fetch_api(url):
res = urllib2.urlopen(url)
def fetch_api_hits(url, number_of_hits):
for i in range(number_of_hits):
fetch_api(url)
print i
def fetch_api_concurrent_users(url, number_of_hits, number_of_users):
for i in range(number_of_users):
thread.start_new_thread(fetch_api_hits, (url, number_of_users,))
if __name__ == '__main__':
url = sys.argv[1]
number_of_hits = int(sys.argv[2])
number_of_users = int(sys.argv[3])
fetch_api_concurrent_users(url, number_of_hits, number_of_users)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment