Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.064 X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; 'anyway.': 0.05; 'subject:skip:t 10': 0.09; 'def': 0.12; "wouldn't": 0.14; 'windows': 0.15; 'paused': 0.16; 'semantics': 0.16; 'time.time()': 0.16; 'wrote:': 0.18; 'mechanism': 0.19; 'normally': 0.19; 'thu,': 0.19; 'seems': 0.21; 'machine': 0.22; '>>>': 0.22; 'import': 0.22; 'putting': 0.22; '>>>': 0.24; 'script': 0.25; '>': 0.26; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'appear': 0.29; 'dec': 0.30; 'relative': 0.30; 'see,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'concern': 0.31; 'exclude': 0.31; 'linux.': 0.31; 'produces': 0.31; 'this.': 0.32; 'call.': 0.33; 'cases': 0.33; 'period': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'similar': 0.36; 'seconds': 0.37; 'so,': 0.37; 'clear': 0.37; 'skip:& 10': 0.38; 'stopped': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'duration': 0.60; 'ian': 0.60; 'numbers': 0.61; 'simply': 0.61; 'story': 0.63; 'skip:6 10': 0.63; 'different': 0.65; 'increasing': 0.74; 'macbook': 0.84; 'subject:over': 0.84; 'suspended,': 0.84; 'shocked': 0.91; 'suspension.': 0.91; 'reducing': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=/3kPbgpGlGzsaHD18uYhVp3mIczKNZ462eHDb1Rz/DI=; b=hZumBsKDgdV+aFLnVs0bRi0Ew2r3PKcDT7FmT5jhpzMrBp7JJH8UwinPIbpTLhVY6B LwtDLa+Kw+spuASNLn4n9ELL/dPZeJ+JCAloziYY7bnEdNmG1C6y3EtTOLkGinc1TkA7 M6ef322i/hQhs9Tuzp63MWoecxQ1l8WgOqQo8ep4GBDo8vsnGpmV3Ta/Y4RWB0zB2lEe Lkx7gDNgYent21lUMsU3vPpbjqf7vc/ZLA6EP4wXFkzN7/5UyzMzFnEI4zhKhi0LxmnX ykNkOI4Hxav5fA5o5+VzPR3H3i0KGw6tBIFeSwnD62YVCxsXomJEUqots5I+KziePPp6 wkYw== X-Received: by 10.66.245.167 with SMTP id xp7mr29280600pac.134.1417799134559; Fri, 05 Dec 2014 09:05:34 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <87r3wfnih0.fsf@elektro.pacujo.net> References: <54807cfd$0$2311$426a74cc@news.free.fr> <87vblr8lcw.fsf@elektro.pacujo.net> <87r3wf8jy8.fsf@elektro.pacujo.net> <87ppbzp9qq.fsf@elektro.pacujo.net> <87wq6788op.fsf@gmail.com> <87r3wfnih0.fsf@elektro.pacujo.net> From: Ian Kelly Date: Fri, 5 Dec 2014 10:04:54 -0700 Subject: Re: time.monotonic() roll over To: Python Content-Type: multipart/alternative; boundary=047d7b1117c9c7475405097b1589 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 94 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1417799143 news.xs4all.nl 2839 [2001:888:2000:d::a6]:42179 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82006 --047d7b1117c9c7475405097b1589 Content-Type: text/plain; charset=UTF-8 On Thu, Dec 4, 2014 at 3:44 PM, Marko Rauhamaa wrote: > > Ian Kelly : > > > It's not clear to me whether those cases are relevant to the rollover > > concern anyway. I wouldn't be shocked if the GetTickCount() function > > simply stopped increasing while the system is suspended, since after > > all it's not "ticking" during that time. > > So, what's the semantics of time.sleep(), select.select() et al wrt > process or machine suspension? Rather than continue to speculate, I just tested this. I ran the following script in a Windows 7 VM and paused the VM for part of the duration of the sleep call. I unpaused well before the sleep call would normally have ended. >>> import time >>> def test(): ... t1 = time.time() ... m1 = time.monotonic() ... time.sleep(60) ... t2 = time.time() ... m2 = time.monotonic() ... return t2 - t1, m2 - m1 ... >>> test() (84.92642459869386, 60.002399999999994) As you can see, the sleep call and the monotonic time elapsed both appear to exclude the period when the VM was paused. Then I tried the same with a MacBook and putting the system to sleep instead of pausing a VM: >>> test() (59.889225006103516, 60.00102640298428) Reducing the sleep time to 10 seconds and suspending the process with Ctrl-Z produces a similar result on the MacBook: (10.000508069992065, 10.000266332994215) But the story is different in Linux. Here's what I got with the same Ctrl-Z test: (16.000478506088257, 16.000478034024127) I think the relative roundness of those numbers is just coincidence. I tried a second time and got: (12.613622903823853, 12.613622067990946) So it seems that it can go either way depending on the OS and perhaps the mechanism of suspension. --047d7b1117c9c7475405097b1589 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Thu, Dec 4, 2014 at 3:44 PM, Marko Rauhamaa <marko@pacujo.net> wrote:
>
>= ; Ian Kelly <ian.g.kelly@gmail.= com>:
>
> > It's not clear to me whether those ca= ses are relevant to the rollover
> > concern anyway. I wouldn'= t be shocked if the GetTickCount() function
> > simply stopped inc= reasing while the system is suspended, since after
> > all it'= s not "ticking" during that time.
>
> So, what's = the semantics of time.sleep(), select.select() et al wrt
> process or= machine suspension?

Rather than continue to speculate, I just = tested this. I ran the following script in a Windows 7 VM and paused the VM= for part of the duration of the sleep call. I unpaused well before the sle= ep call would normally have ended.

>>> im= port time
>>> def test():
... =C2=A0 t1 = =3D time.time()
... =C2=A0 m1 =3D time.monotonic()
... = =C2=A0 time.sleep(60)
... =C2=A0 t2 =3D time.time()
...= =C2=A0 m2 =3D time.monotonic()
... =C2=A0 return t2 - t1, m2 - m= 1
...
>>> test()
(84.926424598= 69386, 60.002399999999994)

As you can see, the= sleep call and the monotonic time elapsed both appear to exclude the perio= d when the VM was paused.

Then I tried the same wi= th a MacBook and putting the system to sleep instead of pausing a VM:
=

>>> test()
(59.889225006103516, 60.0= 0102640298428)

Reducing the sleep time to 10 secon= ds and suspending the process with Ctrl-Z produces a similar result on the = MacBook:
(10.000508069992065, 10.000266332994215)
<= br>
But the story is different in Linux. Here's what I got wi= th the same Ctrl-Z test:
(16.000478506088257, 16.000478034024127)=

I think the relative roundness of those numbe= rs is just coincidence. I tried a second time and got:
(12.613622= 903823853, 12.613622067990946)

So it seems tha= t it can go either way depending on the OS and perhaps the mechanism of sus= pension.
--047d7b1117c9c7475405097b1589--