[openstack-dev] time.sleep is affected by eventlet.monkey_patch()

victor stinner victor.stinner at enovance.com
Fri Mar 7 11:43:03 UTC 2014


Yes, a monotonic *must* be used to compute timeouts. I wrote the time.monotonic() function of Python 3.3 and the PEP 418. For my Trollius project, I wrote this code for Python 2 using ctypes. It works on Linux, Windows, Mac OS X, OpenBSD, FreeBSD and Solaris:

There are existing Python modules, examples:

Any other many projecs have their own implementation.

Read also the 418 for the background:

FYI On Linux, since the glibc 2.17, clock_gettime() is provided by the libc. On older glibc versions, it is provided by librt.


----- Mail original -----
> De: "Yuriy Taraday" <yorik.sar at gmail.com>
> À: "OpenStack Development Mailing List (not for usage questions)" <openstack-dev at lists.openstack.org>
> Envoyé: Vendredi 7 Mars 2014 08:52:56
> Objet: Re: [openstack-dev] time.sleep is affected by	eventlet.monkey_patch()
> On Fri, Mar 7, 2014 at 11:20 AM, Yuriy Taraday < yorik.sar at gmail.com > wrote:
> All in all it sounds like an eventlet bug. I'm not sure how it can be dealt
> with though.
> Digging into it I found out that eventlet uses time.time() by default that is
> not monotonic. There's no clear way to replace it, but you can workaround
> this:
> 1. Get monotonic clock function here:
> http://stackoverflow.com/a/1205762/238308 (note that for FreeBSD or MacOS
> you'll have to use different constant).
> 2. Make eventlet's hub use it:
> eventlet.hubs._threadlocal.hub =
> eventlet.hubs.get_default_hub().Hub(monotonic_time)
> --
> Kind regards, Yuriy.
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

More information about the OpenStack-dev mailing list