Skip to content

Instantly share code, notes, and snippets.

@kenshinx
Created June 27, 2013 02:24
Show Gist options
  • Save kenshinx/5873490 to your computer and use it in GitHub Desktop.
Save kenshinx/5873490 to your computer and use it in GitHub Desktop.
import threading
import requests
#Reference for weirong.
Max_concurrency = 50
def request(url):
resp = requests.get(url)
print "%s status code:%d\n" %(url,resp.status_code)
# print resp.text
return resp.text
def start():
url = "http://weibo.com"
threads = []
for i in range(Max_concurrency):
thread= threading.Thread(target=request,args=(url,))
threads.append(thread)
[t.start() for t in threads]
[t.join() for t in threads]
if __name__ == '__main__':
start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment