Thank you Alessandro ... gearbox#gevent has solved the strange behavior. Now I have an open stream which I can use to send events to the client and the web-page is loaded without being blocked.
But if you will permit, I will continue with another question to complete this work. What is the correct way to handle connection closed by client? ... explanation is following. To maintain opened a connection I use advices founded in streaming#streaming-with-generators <http://turbogears.readthedocs.org/en/latest/cookbook/streaming.html#streaming-with-generators> page, with the only difference that I should interrupt while cycle only when the client has disconnected. When the client is resetting the connection for example when refreshing the page... I get this error when trying to send an event to the client, after the connection was closed: Traceback (most recent call last): File "/virtenv/lib/python2.7/site-packages/gevent/pywsgi.py", line 508, in handle_one_response self.run_application() File "/virtenv/lib/python2.7/site-packages/gevent/pywsgi.py", line 495, in run_application self.process_result() File "/virtenv/lib/python2.7/site-packages/gevent/pywsgi.py", line 486, in process_result self.write(data) File "/virtenv/lib/python2.7/site-packages/gevent/pywsgi.py", line 376, in write self._write(data) File "/virtenv/lib/python2.7/site-packages/gevent/pywsgi.py", line 369, in _write self._sendall(data) File "/virtenv/lib/python2.7/site-packages/gevent/pywsgi.py", line 355, in _sendall self.socket.sendall(data) File "/virtenv/lib/python2.7/site-packages/gevent/socket.py", line 458, in sendall data_sent data_sent += self.send(_get_memory(data, data_sent), flags) File "/virtenv/lib/python2.7/site-packages/gevent/socket.py", line 435, in send return sock.send(data, flags) error: [Errno 32] Broken pipe somewhere I found that in a wsgi environment I could use while True: websocket = request.environ['wsgi.websocket'] if not websocket.socket: break else: send_next_event() closed_connection_handler() but apparently, this is not a solution for Turbogears as there is not a wsgi.websocket key in request.environ dictionary. And I can't find a gevent environment variable suitable for this. As always, I will be glad for any suggestion. Thanks. -- You received this message because you are subscribed to the Google Groups "TurboGears" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/turbogears. For more options, visit https://groups.google.com/d/optout.

