Gunicorn Worker timeout timestamp too large to convert to C _PyTime_t

I am trying to start my flask application using gunicorn with one worker but it returns this error

OverflowError: timestamp too large to convert to C _PyTime_t

This is the command I am using to fire gunicorn

gunicorn app:app -b \
  --name $APP_NAME \
  --workers 1\
  --timeout 9999999 \

Here is the stack trace,

Traceback (most recent call last):

File "/usr/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
  File "/usr/lib/python3.6/site-packages/gunicorn/workers/base.py", line 134, in init_process
  File "/usr/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 124, in run
  File "/usr/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 83, in run_for_one
  File "/usr/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 35, in wait
    ret = select.select(self.wait_fds, [], [], timeout)
OverflowError: timestamp too large to convert to C _PyTime_t

I read few questions but all says to reduce timeout which I already reduced. I don't why it is not working.

Thank you!

- - Source


answered 1 week ago prithajnath #1

That value is too big for the underlying C data type (INT). The gunicorn --timeout flag accepts the value in seconds, and generally speaking, if you have to keep a worker alive for that long (~116 days) you're probably doing something wrong. A worker should suspend a connection after a reasonable amount of time to free up resources. If you have some compute heavy endpoint that takes a while, you should still have a good estimation of how long that endpoint would normally take and adjust your gunicorn --timeout parameter accordingly. Things that take longer than a standard HTTP request/response cycle should be moved to a task queue such as Redis or RabbitMQ. You haven't given much information on what exactly your Flask application is doing so I'm speaking in very general terms. That being said, it's probably okay for you to leave out the --timeout flag. I think the default for sync workers is 30s which is very reasonable for a typical web app

comments powered by Disqus