--
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-tornad...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Put this at module scope:db = motor.MotorClient().my_databaseYou could stick that in a db.py and then "from db import db" wherever you want it. Or, put it in the application:tornado.web.Application(urls, db=db)Then every RequestHandler gets the same db instance in self.settings['db'].
Sorry to necro a thread, redis-py claims to be thread safe (https://github.com/andymccurdy/redis-py#thread-safety):
"Redis client instances can safely be shared between threads. Internally, connection instances are only retrieved from the connection pool during command execution, and returned to the pool directly after. Command execution never modifies state on the client instance."
Does this mean I can safely initialize a redis client before the fork, and use the same client across all my child processes?
For more options, visit https://groups.google.com/d/optout.
This peaqued my interest, just wanted to share further educational material: http://linuxjournal.com/content/three-ways-web-server-concurrency