librelist archives

« back to archive

How to stop running Flask application?

How to stop running Flask application?

From:
Francisco Souza
Date:
2011-01-08 @ 03:01
Hi everyone,
is there a way to stop a Flask application?

I'm writing some acceptance tests and I call app.run() in a global "setup"
method, then I'd like to call something like app.stop() on "teardown".

How can I do this?

Regards,
Francisco Souza
Software developer at Giran and also full time
Open source evangelist at full time

English: http://www.franciscosouza.com
Portuguese: http://www.franciscosouza.com.br
Twitter: @franciscosouza
+55 27 3026 0264

Re: [flask] How to stop running Flask application?

From:
Nikolaus Graf
Date:
2011-01-08 @ 10:29
I had the same problem when i started doing selenium tests on our app 
engine apps and come up with this workaround.
Starting the server as a subprocess and killing it in the end. If you are 
on python2.6+ you can use "self.server.kill()".

greetings nik


def setUp(self):
    self.server = Popen("dev_appserver.py . --port=80", shell=True)

def tearDown(self):
    # same as Popen.kill() in python2.6 for posix OSs (so currently no 
windows support)
    os.kill(self.server.pid, signal.SIGTERM)


On Jan 8, 2011, at 4:01 AM, Francisco Souza wrote:

> Hi everyone,
> is there a way to stop a Flask application?
> 
> I'm writing some acceptance tests and I call app.run() in a global 
"setup" method, then I'd like to call something like app.stop() on 
"teardown".
> 
> How can I do this?
> 
> Regards,
> Francisco Souza
> Software developer at Giran and also full time
> Open source evangelist at full time
> 
> English: http://www.franciscosouza.com
> Portuguese: http://www.franciscosouza.com.br
> Twitter: @franciscosouza
> +55 27 3026 0264