s243a

gevent.queue example

Nov 3rd, 2018
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. # https://bottlepy.org/docs/dev/async.html
  2. @route('/fetch')
  3. def fetch():
  4.     body = gevent.queue.Queue()
  5.     worker = SomeAsyncWorker()
  6.     worker.on_data(body.put)
  7.     worker.on_finish(lambda: body.put(StopIteration))
  8.     worker.start()
  9.     return body
Advertisement
Add Comment
Please, Sign In to add comment