librelist archives

« back to archive

Issue with flask not accepting commands after a certain time

Issue with flask not accepting commands after a certain time

From:
Norbert Markowicz
Date:
2013-03-14 @ 17:54
Hi All,

I'm running a data acquisition system with html/JS interface that pulls the
current values every second from the server side.
All works well when I access the page locally or on another machine on the
same local network. However, when accessed remotely, flask becomes
unresponsive after some time to any commands, json pulls of current values,
or even simple page loads of sites on the server, all of which behaving
fine when I started the session.
There is no error generated at all, even though I have debug mode on in
flask.

From the linux end on the server side, I can still see the python process
is still showing as active. However, as stated above, I cannot get it to
respond to a command (i.e. process a request) or, even load any page on the
server.

Any insights/input would be greatly appreciated.

-Norbert

Re: [flask] Issue with flask not accepting commands after a certain time

From:
Steven Kryskalla
Date:
2013-03-14 @ 18:32
On Thu, Mar 14, 2013 at 10:54 AM, Norbert Markowicz
<norbert.markowicz@gmail.com> wrote:
> From the linux end on the server side, I can still see the python process is
> still showing as active. However, as stated above, I cannot get it to
> respond to a command (i.e. process a request) or, even load any page on the
> server.

Which server are you using? The built-in one with flask? Are you using
the reloader or debugger? Do you have any long running requests that
could be blocking?

If you're using the flask/werkzeug debug server, try switching to a
production wsgi server, like one of these:

https://pypi.python.org/pypi/waitress
http://gunicorn.org/
http://projects.unbit.it/uwsgi/
https://code.google.com/p/modwsgi/
http://docs.cherrypy.org/stable/refman/wsgiserver/init.html

I recommend waitress (since it's pure python and easiest to set up) or
gunicorn to start. See if the problem goes away with either of those.

-Steve

Re: [flask] Issue with flask not accepting commands after a certain time

From:
Steven Kryskalla
Date:
2013-03-14 @ 18:35
On Thu, Mar 14, 2013 at 11:32 AM, Steven Kryskalla <skryskalla@gmail.com> wrote:
> On Thu, Mar 14, 2013 at 10:54 AM, Norbert Markowicz
> <norbert.markowicz@gmail.com> wrote:
>> From the linux end on the server side, I can still see the python process is
>> still showing as active. However, as stated above, I cannot get it to
>> respond to a command (i.e. process a request) or, even load any page on the
>> server.

Also, to troubleshoot this kind of thing (hung process, server not
responding), I'd try using strace on the python process to see what
it's doing:

$ strace -s4096 -fTtp <pid of python process>

-steve