Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workers unexpectedly time out if system time changes #1709

Closed
flixr opened this issue Feb 19, 2018 · 4 comments
Closed

workers unexpectedly time out if system time changes #1709

flixr opened this issue Feb 19, 2018 · 4 comments

Comments

@flixr
Copy link

flixr commented Feb 19, 2018

Worker timeouts currently use the system clock for checking timeouts, delays, etc..
This is not robust as the system time might jump (e.g. due to NTP, PTP or other time updates)

IMHO these timeouts should use the monotonic clock as here we never care about the system time, but just the real elapsed time to check whether we need to kill a worker.

@tilgovi
Copy link
Collaborator

tilgovi commented Feb 20, 2018

Looks like time.monotonic() is only guaranteed to exist since Python 3.5, but if it's there we should, perhaps, use it for things.

@flixr
Copy link
Author

flixr commented Feb 20, 2018

It should be available since Python 3.3, but we could (IMHO should) use e.g. https://pypi.python.org/pypi/monotonic to also make this fix available on older Python versions.

Quickly looking through the code it doesn't seem to be too hard except that in

return os.fstat(self._tmp.fileno()).st_ctime
we would have to actually store the monotonic time in the file (or something like that) instead of using ctime of the file itself.

@duffsterlp
Copy link

We use gunicorn on an embedded system where the clock ends up jumping ahead due to particular events. When the clock jump occurs, we see this same issue.

@benoitc benoitc added this to the 20.1 milestone Nov 22, 2019
@benoitc benoitc removed this from the 20.1 milestone Jan 7, 2021
@tilgovi
Copy link
Collaborator

tilgovi commented Dec 28, 2023

Closed by #1967.

@tilgovi tilgovi closed this as completed Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants