openfisca / openfisca-core

OpenFisca core engine. See other repositories for countries-specific code & data.
https://openfisca.org
GNU Affero General Public License v3.0
165 stars 74 forks source link

Upgrade Gunicorn Dependency to Resolve SIGTERM Handling Issue #1198

Closed baptou12 closed 9 months ago

baptou12 commented 9 months ago

Hi there!

I really enjoy OpenFisca, but I recently encountered an issue.

Here is what I did:

We recently discovered that when a SIGTERM was sent to openfisca web-api, it could raise some errors :

Stacktrace ``` --- Logging error --- Traceback (most recent call last): File "/usr/local/lib/python3.11/logging/__init__.py", line 1113, in emit stream.write(msg + self.terminator) RuntimeError: reentrant call inside <_io.BufferedWriter name=''> During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.11/logging/__init__.py", line 1113, in emit stream.write(msg + self.terminator) File "/home/main/aides_jeunes/venv/lib/python3.11/site-packages/gunicorn/arbiter.py", line 242, in handle_chld self.reap_workers() File "/home/main/aides_jeunes/venv/lib/python3.11/site-packages/gunicorn/arbiter.py", line 530, in reap_workers self.log.warning( File "/home/main/aides_jeunes/venv/lib/python3.11/site-packages/gunicorn/glogging.py", line 261, in warning self.error_log.warning(msg, *args, **kwargs) File "/usr/local/lib/python3.11/logging/__init__.py", line 1501, in warning self._log(WARNING, msg, args, **kwargs) File "/usr/local/lib/python3.11/logging/__init__.py", line 1634, in _log self.handle(record) File "/usr/local/lib/python3.11/logging/__init__.py", line 1644, in handle self.callHandlers(record) File "/usr/local/lib/python3.11/logging/__init__.py", line 1706, in callHandlers hdlr.handle(record) File "/usr/local/lib/python3.11/logging/__init__.py", line 978, in handle self.emit(record) File "/usr/local/lib/python3.11/logging/__init__.py", line 1118, in emit self.handleError(record) File "/usr/local/lib/python3.11/logging/__init__.py", line 1031, in handleError sys.stderr.write('--- Logging error ---\n') RuntimeError: reentrant call inside <_io.BufferedWriter name=''> Call stack: File "/home/main/aides_jeunes/venv/bin/gunicorn", line 8, in sys.exit(run()) File "/home/main/aides_jeunes/venv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 67, in run WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run() File "/home/main/aides_jeunes/venv/lib/python3.11/site-packages/gunicorn/app/base.py", line 231, in run super().run() File "/home/main/aides_jeunes/venv/lib/python3.11/site-packages/gunicorn/app/base.py", line 72, in run Arbiter(self).run() File "/home/main/aides_jeunes/venv/lib/python3.11/site-packages/gunicorn/arbiter.py", line 209, in run self.sleep() File "/home/main/aides_jeunes/venv/lib/python3.11/site-packages/gunicorn/arbiter.py", line 357, in sleep ready = select.select([self.PIPE[0]], [], [], 1.0) File "/home/main/aides_jeunes/venv/lib/python3.11/site-packages/gunicorn/arbiter.py", line 242, in handle_chld self.reap_workers() File "/home/main/aides_jeunes/venv/lib/python3.11/site-packages/gunicorn/arbiter.py", line 539, in reap_workers worker.tmp.close() File "/home/main/aides_jeunes/venv/lib/python3.11/site-packages/gunicorn/workers/workertmp.py", line 55, in close return self._tmp.close() File "/home/main/aides_jeunes/venv/lib/python3.11/site-packages/gunicorn/arbiter.py", line 242, in handle_chld self.reap_workers() File "/home/main/aides_jeunes/venv/lib/python3.11/site-packages/gunicorn/arbiter.py", line 530, in reap_workers self.log.warning( File "/home/main/aides_jeunes/venv/lib/python3.11/site-packages/gunicorn/glogging.py", line 261, in warning self.error_log.warning(msg, *args, **kwargs) Message: 'Worker with pid %s was terminated due to signal %s' ```

Here is what I expected to happen:

Gunicorn had a bug which is already resolved linked to this stack. https://github.com/benoitc/gunicorn/issues/2564

Here is what actually happened:

In Openfisca-Core, Gunicorn versio is capped <21 but bug resolution needs >=21

I identify more as a:

bonjourmauko commented 9 months ago

Hi @baptou12 ! Thanks for reporting this issue. Could you please check if the proposed solution does actually solve the issue in your country package and update this issue's description or add a comment to it?