diff options
author | Marcel Hellkamp <marc@gsites.de> | 2013-12-03 08:50:29 -0800 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2013-12-03 08:50:29 -0800 |
commit | 4baea196dabf9492949fdcacff70658adb02ef16 (patch) | |
tree | 68da966e5e2f2d84a905865e3ec427efa4e73c9b /docs | |
parent | d1cea5d23e7e2b647ae7acd22f7490e4c6cc6187 (diff) | |
parent | 58ccccddb06392bb28a01827e70ce32d64dc7d43 (diff) | |
download | bottle-4baea196dabf9492949fdcacff70658adb02ef16.tar.gz |
Merge pull request #465 from enriquepablo/master
Little documentation improvement (?)
Diffstat (limited to 'docs')
-rw-r--r-- | docs/async.rst | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/docs/async.rst b/docs/async.rst index c6c39e9..da40827 100644 --- a/docs/async.rst +++ b/docs/async.rst @@ -70,8 +70,9 @@ In order to conform to the WSGI standard, all we have to do is to return a body def fetch(): body = gevent.queue.Queue() worker = SomeAsyncWorker() - worker.on_data(lambda chunk: body.put(chunk)) + worker.on_data(body.put) worker.on_finish(lambda: body.put(StopIteration)) + worker.start() return body From the server perspective, the queue object is iterable. It blocks if empty and stops as soon as it reaches ``StopIteration``. This conforms to WSGI. On the application side, the queue object behaves like a non-blocking socket. You can write to it at any time, pass it around and even start a new (pseudo)thread that writes to it asynchronously. This is how long-polling is implemented most of the time. |