> I have a client that makes a long standing http call, which can take a
> while, using gevent like described here:
> http://projects.unbit.it/uwsgi/wiki/Gevent
>
> But during the request, I need a way to detect if the client has closed
> the
> connection.
>
> Since I´m using cherry for my dispatching, I want to be able to do
> something like this: http://tools.cherrypy.org/wiki/IsClientConnected
>
> If course when using uwsgi we don´t have the rfile.rfile._sock but I was
> able to find the file descriptor for the uwsgi socket like this
>
> fileDescriptor = int(cherrypy.request.wsgi_environ["wsgi.input"].fileno())
> fileDescriptorState = fcntl.fcntl(fileDescriptor, fcntl.F_GETFD)
>
> but it seems all connections come across the same socket, which I assume
> is
> the connection from nginx to uwsgi.

you have to use uwsgi.connection_fd() as wsgi.input take in account lot of
conditions, so it could map to different objects.

Then, be sure you have consumed the request body, and after that you can
poll (using the gevent api for read) the uwsgi.connection_fd(), if it
returns an event the connection has been closed.

-- 
Roberto De Ioris
http://unbit.it
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to