Created
June 27, 2013 02:24
-
-
Save kenshinx/5873490 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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