python 运行时错误:〈_io. BufferedWriter name =''>内部的可重入调用< stderr>'&gt;

hm2xizp9  于 2023-01-16  发布在  Python
关注(0)|答案(1)|浏览(226)

我正在运行Nginx + Gunicorn + FastAPI应用程序。我的文件main.py中有一个相当简单的ML应用程序。
我使用本手册设置(俄语翻译):[1][2][3][4][5]
当我试着检查
gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app
我看到此错误

File "/var/www/ste/venv/lib/python3.8/site-packages/gunicorn/arbiter.py", line 211, in run
    self.manage_workers()
  File "/var/www/ste/venv/lib/python3.8/site-packages/gunicorn/arbiter.py", line 551, in manage_workers
    self.spawn_workers()
  File "/var/www/ste/venv/lib/python3.8/site-packages/gunicorn/arbiter.py", line 623, in spawn_workers
    time.sleep(0.1 * random.random())
  File "/var/www/ste/venv/lib/python3.8/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
    self.reap_workers()
  File "/var/www/ste/venv/lib/python3.8/site-packages/gunicorn/arbiter.py", line 530, in reap_workers
    self.log.warning(
  File "/var/www/ste/venv/lib/python3.8/site-packages/gunicorn/glogging.py", line 261, in warning
    self.error_log.warning(msg, *args, **kwargs)
  File "/usr/lib/python3.8/logging/__init__.py", line 1458, in warning
    self._log(WARNING, msg, args, **kwargs)
  File "/usr/lib/python3.8/logging/__init__.py", line 1589, in _log
    self.handle(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 1599, in handle
    self.callHandlers(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 1661, in callHandlers
    hdlr.handle(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 954, in handle
    self.emit(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 1093, in emit
    self.handleError(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 1007, in handleError
    traceback.print_exception(t, v, tb, None, sys.stderr)
  File "/usr/lib/python3.8/traceback.py", line 105, in print_exception
    print(line, file=file, end="")
  File "/var/www/ste/venv/lib/python3.8/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
    self.reap_workers()
  File "/var/www/ste/venv/lib/python3.8/site-packages/gunicorn/arbiter.py", line 530, in reap_workers
    self.log.warning(
  File "/var/www/ste/venv/lib/python3.8/site-packages/gunicorn/glogging.py", line 261, in warning
    self.error_log.warning(msg, *args, **kwargs)
  File "/usr/lib/python3.8/logging/__init__.py", line 1458, in warning
    self._log(WARNING, msg, args, **kwargs)
  File "/usr/lib/python3.8/logging/__init__.py", line 1589, in _log
    self.handle(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 1599, in handle
    self.callHandlers(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 1661, in callHandlers
    hdlr.handle(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 954, in handle
    self.emit(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 1093, in emit
    self.handleError(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 1006, in handleError
    sys.stderr.write('--- Logging error ---\n')
RuntimeError: reentrant call inside <_io.BufferedWriter name='<stderr>'>
[2022-02-21 21:02:44 +0300] [650] [WARNING] Worker with pid 656 was terminated due to signal 4 ```

I have file main.py and app in it. Any ideas how to handle this error?

  [1]: https://pythobyte.com/deploy-fastapi-application-on-ubuntu-with-nginx-gunicorn-and-uvicorn-3mbl-f789b2df/
u5rb5r59

u5rb5r591#

检查Ubuntu核心的版本,如果有人会处理这样的错误。

相关问题