@mike - yes, uwsgi is that kind of server. It takes advantage of 
copy-on-write memory

This sounds like Jens is connecting to the database before it forks 
(usually any code that isn't wrapped in request logic)

uwsgi has a postfork hook, which can be handled via a decorator 
(http://uwsgi-docs.readthedocs.io/en/latest/PythonDecorators.html#uwsgidecorators.postfork)
 
or api.

the common way to handle this is with a fixup routine, and `dispose` on 
each engine 
(http://docs.sqlalchemy.org/en/latest/core/connections.html#sqlalchemy.engine.Engine.dispose)

    def my_atfork():
        for engine in models.engines:
            engine.dispose()
  
i have a tiny intregration for it under pyramid available on pypi 
(https://github.com/jvanasco/pyramid_forksafe) , which I only packaged up 
because we occasionally run things on gunicorn and I maintaining two fixups 
was annoying.   the key thing to look at is in my uwsgi `container` code 
(https://github.com/jvanasco/pyramid_forksafe/blob/master/pyramid_forksafe/containers/uwsgi.py)
 
and the try/except with the uwsgidecorators package.  that package is only 
loaded when you're running under uwsgi - it's not otherwise available in 
the same python environment.  you need to wrap it in a try/except, 
otherwise your app won't run under pserve/waitress or any other development 
framework.




-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to