[Python-Dev] Drop the new time.wallclock() function?

Yury Selivanov yselivanov.ml at gmail.com
Sat Mar 24 00:21:57 CET 2012


On 2012年03月23日, at 7:07 PM, Victor Stinner wrote:
> 2012年3月23日 Yury Selivanov <yselivanov.ml at gmail.com>:
>> Why can't I use select & threads? You mean that if a platform does not
>> support monotonic clocks it also does not support threads and select sys
>> call?
>> Python 3.3 now uses time.steady(strict=False) in the threading and
> queue modules. If we replace it by time.steady(strict=True), you may
> get an error if your platform doesn't provide a monotonic clock and so
> you cannot use these modules.

Why this won't work?
try:
 from time import monotonic as _time
except ImportError:
 from time import time as _time
OR (if we decide to fail on first call, instead of ImportError)
import time
try:
 time.monotonic()
except OSError:
 _time = time
else:
 _time = time.monotonic
And then just use '_time' in your code? What's the deal with the
'strict' kwarg?
I really like how it currently works with epoll, for instance. It either
exists in the 'select' module, or not, if the host OS doesn't support it.
I think it should be the same for 'time.monotonic'.
-
Yury


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /