Skip to content

Instantly share code, notes, and snippets.

Created July 8, 2014 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/e2ed7a6e0f15df9d8122 to your computer and use it in GitHub Desktop.
Save anonymous/e2ed7a6e0f15df9d8122 to your computer and use it in GitHub Desktop.
example.py
import gevent, gevent.queue
MAX = 0
def send_mail(sent_to, msg):
print "sent_to:", sent_to, "\tmessage:", msg
def background(queue):
for args in queue:
send_mail(*args)
print 'background exit'
queue = gevent.queue.Queue(MAX)
background = gevent.spawn(background, queue)
queue.put(("a@a.com", "hi, a"))
queue.put(("a@a.com", "hi, b"))
queue.put(("a@a.com", "hi, c"))
queue.put(StopIteration)
background.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment