Discussion:
[tornado] Tornado server startup hooks
Sam Frances
2018-07-11 10:52:47 UTC
Permalink
Is there a standard way to schedule code to run when the tornado server
first starts up, which also integrates well with tornado's testing
framework (so that these tasks are also automatically run when the test
class starts the server)? The documentation isn't proving much help here. I
can create a "start_server" function which starts the server and schedules
startup tasks by directly invoking the event loop, but that doesn't gel
well with the testing framework, whereby you are supposed to specify the
"get_app" method and leave the testing framework to start the server.
--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornado+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ben Darnell
2018-07-15 22:07:26 UTC
Permalink
There are no specific hooks for this, but you can use the standard test
setUp/tearDown methods. Or you can just schedule your tasks from `get_app`
(or in the app constructor itself). That's a bit unclean but it's fair to
assume that get_app will be called exactly once, right before the server is
started.

-Ben
Post by Sam Frances
Is there a standard way to schedule code to run when the tornado server
first starts up, which also integrates well with tornado's testing
framework (so that these tasks are also automatically run when the test
class starts the server)? The documentation isn't proving much help here. I
can create a "start_server" function which starts the server and schedules
startup tasks by directly invoking the event loop, but that doesn't gel
well with the testing framework, whereby you are supposed to specify the
"get_app" method and leave the testing framework to start the server.
--
You received this message because you are subscribed to the Google Groups
"Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornado+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...