Abhilash Raj pushed to branch master at GNU Mailman / Mailman Core


Commits:
88bb6f9f by Abhilash Raj at 2021-06-19T06:31:16+00:00
Dispose all database connections after a new worker process forks.

- - - - -
6da77581 by Abhilash Raj at 2021-06-19T06:31:16+00:00
Merge branch 'engine' into 'master'

Dispose all database connections after a new worker process forks.

Closes #854

See merge request mailman/mailman!864
- - - - -


2 changed files:

- src/mailman/docs/NEWS.rst
- src/mailman/rest/gunicorn.py


Changes:

=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -75,6 +75,9 @@ Bugs
   RFC 7849.  (Closes #907)
 * Held messages missing from the message store can now be accepted and/or
   forwarded.  (closes #914)
+* Dispose SQLAlchemy connections after a new worker process is forked. (Closes
+  #854)
+
 
 Command line
 ------------


=====================================
src/mailman/rest/gunicorn.py
=====================================
@@ -44,6 +44,14 @@ class GunicornApplication(gunicorn.app.base.BaseApplication):
         return self.application
 
 
+def _post_worker_init(worker):
+    """Post worker initialize event handler for Gunicorn."""
+    # Dispose engine connections whenever a new process is forked and
+    # initialized so they don't step on each other's connections.
+    # https://docs.gunicorn.org/en/latest/settings.html#post-worker-init
+    config.db.engine.dispose()
+
+
 @public
 def make_gunicorn_server():
     """Create a gunicorn server.
@@ -64,6 +72,7 @@ def make_gunicorn_server():
         'access_log_format': config.logging.http['format'],
         'disable_redirect_access_to_syslog': True,
         'workers': int(config.webservice.workers),
+        'post_worker_init': _post_worker_init,
         }
     # Read the ini configuration and pass those values to the
     # GunicornApplication.



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/0a5c5ec414e0aabb91d912b1f2636d38765affed...6da77581e7a4ae29a21dde6db813c082130c762f

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/0a5c5ec414e0aabb91d912b1f2636d38765affed...6da77581e7a4ae29a21dde6db813c082130c762f
You're receiving this email because of your account on gitlab.com.


_______________________________________________
Mailman-checkins mailing list -- mailman-checkins@python.org
To unsubscribe send an email to mailman-checkins-le...@python.org
https://mail.python.org/mailman3/lists/mailman-checkins.python.org/
Member address: arch...@jab.org

Reply via email to