Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Spawn a thread and make the greenlet wait for it to exit.
from __future__ import print_function
import time
import gevent
from gevent import hub, _threading
def ticker():
while True:
print('tick')
gevent.sleep(1)
def listen():
def worker():
time.sleep(5)
watcher.send()
watcher = hub.get_hub().loop.async()
_threading.start_new_thread(worker, ())
hub.get_hub().wait(watcher)
gevent.spawn(ticker)
print('listen starting')
listen()
print('listen stopped')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.