Skip to content

Instantly share code, notes, and snippets.

@codingjester
Created July 31, 2012 21:18
Show Gist options
  • Save codingjester/3220655 to your computer and use it in GitHub Desktop.
Save codingjester/3220655 to your computer and use it in GitHub Desktop.
Python threading really fast
#!/usr/bin/env python
import threading
import Queue
import time
class Blarg(threading.Thread):
def run(self):
print time.time()
q = Queue.Queue()
for i in range(10):
b = Blarg()
b.start()
q.join()
@ohpauleez
Copy link

You could also just use futures (back ported to 2.7 - and can be switched to multiprocessing).

I more commonly see:

def some_func():
    return 5

t = threading.Thread(target=some_func)
t.start()

@codingjester
Copy link
Author

ah hah! Thanks for that! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment