Skip to content

Instantly share code, notes, and snippets.

@shikendon
Last active August 23, 2022 11:53
Show Gist options
  • Save shikendon/e47dcc03cb8f31048049c55bad533b61 to your computer and use it in GitHub Desktop.
Save shikendon/e47dcc03cb8f31048049c55bad533b61 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import threading
import urllib.request
def worker(index, results):
req = urllib.request.urlopen('https://www.facebook.com/')
results.append(req.getcode())
results = []
threads = []
for i in range(1000):
t = threading.Thread(target=worker, args=(i, results))
threads.append(t)
t.start()
for t in threads:
t.join()
print(set(results))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment