[issue14222] Using time.time() in Queue.get breaks when system time is changed

2012-03-19 Thread STINNER Victor

STINNER Victor  added the comment:

> Yo, I had marked this as something I was going to review once
> the python-dev discussion to complete.  FWIW, I'm the maintainer
> of the Queue module.

And so, do you agree with the change?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14222] Using time.time() in Queue.get breaks when system time is changed

2012-03-14 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Yo, I had marked this as something I was going to review once the python-dev 
discussion to complete.  FWIW, I'm the maintainer of the Queue module.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14222] Using time.time() in Queue.get breaks when system time is changed

2012-03-14 Thread Roundup Robot

Roundup Robot  added the comment:

New changeset d97ae725814c by Victor Stinner in branch 'default':
Issue #14222: Use the new time.steady() function instead of time.time() for
http://hg.python.org/cpython/rev/d97ae725814c

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14222] Using time.time() in Queue.get breaks when system time is changed

2012-03-14 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee:  -> rhettinger
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14222] Using time.time() in Queue.get breaks when system time is changed

2012-03-14 Thread Charles-François Natali

Charles-François Natali  added the comment:

Random thoughts:
- as noted by Antoine, it probably affects a lot of code throughout
the standard library
- sem_timedwait() (used by lock.acquire() on POSIX) is affected (the
implementation using a condition variable could use
pthread_condattr_setclock(), see issue #12822)
- there's a side effect to that change: on Linux, when the system is
suspended, CLOCK_MONOTONIC stops: so on resume, you'd have to wait for
the complete timeout to expire, whereas with time.time() you'll break
out early

That being said, it's probably a good idea.

As for the patches, I don't really like the idea of having to use this
idiom everywhere:

try:
from time import monotonic as _time
_time()
except (ImportError, OSError):
from time import _time

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14222] Using time.time() in Queue.get breaks when system time is changed

2012-03-14 Thread Matt Joiner

Changes by Matt Joiner :


--
nosy: +anacrolix

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14222] Using time.time() in Queue.get breaks when system time is changed

2012-03-13 Thread STINNER Victor

STINNER Victor  added the comment:

threading_monotonic.patch: similar patch for the threading module.

Drawback of these patchs: they now call time.monotonic() when the module is 
loaded (another useless syscall?).

--
Added file: http://bugs.python.org/file24835/threading_monotonic.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14222] Using time.time() in Queue.get breaks when system time is changed

2012-03-13 Thread STINNER Victor

STINNER Victor  added the comment:

queue_monotonic.patch: simple patch using time.monotonic(), with a fallback to 
time.time() if monotonic failed or is not available.

--
keywords: +patch
Added file: http://bugs.python.org/file24834/queue_monotonic.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14222] Using time.time() in Queue.get breaks when system time is changed

2012-03-07 Thread STINNER Victor

STINNER Victor  added the comment:

> Well, in 3.3 we could use clock_gettime(CLOCK_MONOTONIC) where available.

It's better to use time.monotonic().

> That said, this is not specific to Queue.get() and will probably happen with 
> many similar functions taking a timeout parameter.

Yep, it may be used for lock.acquire(timeout=timeout) for example. It 
would help to have a portable monotonic clock API in C.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14222] Using time.time() in Queue.get breaks when system time is changed

2012-03-07 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Well, in 3.3 we could use clock_gettime(CLOCK_MONOTONIC) where available.
That said, this is not specific to Queue.get() and will probably happen with 
many similar functions taking a timeout parameter.

--
nosy: +haypo, neologix, pitrou

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14222] Using time.time() in Queue.get breaks when system time is changed

2012-03-07 Thread Tasslehoff Kjappfot

New submission from Tasslehoff Kjappfot :

Queue.get([block[, timeout]]) uses time.time() for calculations of the timeout. 
If someone changes the system time this breaks. If a timeout of 1 second is set 
and someone (on a unix system) uses date to set the time 1 hour back, Queue.get 
will use 1 hour and 1 second to time out.

I'm guessing the fix is just to use another library function to measure time, 
but I don't know if one exists that works on all platforms.

--
components: Library (Lib)
messages: 155106
nosy: tasslehoff
priority: normal
severity: normal
status: open
title: Using time.time() in Queue.get breaks when system time is changed
type: behavior
versions: Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com