Skip to content

Instantly share code, notes, and snippets.

@pixyj
Created December 30, 2015 18:57
Show Gist options
  • Save pixyj/336545faf57db3c37c51 to your computer and use it in GitHub Desktop.
Save pixyj/336545faf57db3c37c51 to your computer and use it in GitHub Desktop.
Thread and Queue Python example - blast from my past
import Queue
import threading
class PrintMsg(threading.Thread):
def __init__(self,queue):
threading.Thread.__init__(self)
self.queue = queue
def run(self):
while True:
print "waiting for msg"
msg = self.queue.get()
print "Msg received {}".format(msg)
queue = Queue.Queue()
printMsg = PrintMsg(q)
printMsg.start()
while True:
msg = raw_input("Enter the msg\n")
queue.put(msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment