Skip to content

Odd crash in gthread after page served #3029

Closed
@dale-wahl

Description

@dale-wahl

I just started to see this after rebuilding an older app after making some small changes.

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
    worker.init_process()
  File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/gthread.py", line 95, in init_process
    super().init_process()
  File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 142, in init_process
    self.run()
  File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/gthread.py", line 232, in run
    self.murder_keepalived()
  File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/gthread.py", line 176, in murder_keepalived
    self.poller.unregister(conn.sock)
  File "/usr/local/lib/python3.8/selectors.py", line 366, in unregister
    key = super().unregister(fileobj)
  File "/usr/local/lib/python3.8/selectors.py", line 249, in unregister
    key = self._fd_to_key.pop(self._fileobj_lookup(fileobj))
  File "/usr/local/lib/python3.8/selectors.py", line 225, in _fileobj_lookup
    return _fileobj_to_fd(fileobj)
  File "/usr/local/lib/python3.8/selectors.py", line 42, in _fileobj_to_fd
    raise ValueError("Invalid file descriptor: {}".format(fd))
ValueError: Invalid file descriptor: -1

I was not sure if I was causing it, so I started up a very simple Flask app and was able to reproduce. It serves the home page fine, but a moment later I see the above and the worker restarts.

Command
gunicorn --worker-tmp-dir /dev/shm --workers=1 --threads=4 --worker-class=gthread --log-level=debug --access-logfile=gunicorn_access.log --reload --bind 0.0.0.0:4000 frontend:app

Environment

blinker==1.6.2
click==8.1.5
Flask==2.3.2
gunicorn==21.0.1
importlib-metadata==6.8.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.3
packaging==23.1
Werkzeug==2.3.6
zipp==3.16.2

Will revert to a previous version and see if the error persists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions