[issue31539] asyncio.sleep may sleep less time then it should

2020-02-25 Thread Guido van Rossum
Guido van Rossum added the comment: Markus, your comment does not seem relevant to this issue. Maybe you meant to add it to a different issue, or you meant to create a new issue? -- ___ Python tracker _

[issue31539] asyncio.sleep may sleep less time then it should

2020-02-25 Thread Markus Roth
Markus Roth added the comment: When the fine tuning options for install-directories are set, the default directories "lib", "bin" and "include" are still created with essential content. Even if options like --libdir are set. -- nosy: +CatorCanulis ___

[issue31539] asyncio.sleep may sleep less time then it should

2017-09-21 Thread Yury Selivanov
Yury Selivanov added the comment: > The performance issue was that the asyncio core loop was running in a loop but did nothing because of time rounding. When the next event was in a few nanoseconds, the e event burnt the CPU during seconds. It can be 15 ms on Windows or 1 ms when using poll() fo

[issue31539] asyncio.sleep may sleep less time then it should

2017-09-21 Thread STINNER Victor
STINNER Victor added the comment: Issues: - bpo-20320 - bpo-20452 - bpo-20505 - bpo-20311 The performance issue was that the asyncio core loop was running in a loop but did nothing because of time rounding. When the next event was in a few nanoseconds, the e event burnt the CPU during seconds.

[issue31539] asyncio.sleep may sleep less time then it should

2017-09-21 Thread Yury Selivanov
Yury Selivanov added the comment: So here's the relevant piece of code: end_time = self.time() + self._clock_resolution while self._scheduled: handle = self._scheduled[0] if handle._when >= end_time: break handle = heapq.heappop

[issue31539] asyncio.sleep may sleep less time then it should

2017-09-21 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- nosy: +gvanrossum ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.

[issue31539] asyncio.sleep may sleep less time then it should

2017-09-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: Le 21/09/2017 à 23:31, STINNER Victor a écrit : > > Yury: asyncio can trigger events earlier than scheduled for performance > reasons. If that's true, then it sounds like a bug. If there is a rationale for a "fast and imprecise" API, then it would seem ok to a

[issue31539] asyncio.sleep may sleep less time then it should

2017-09-21 Thread STINNER Victor
STINNER Victor added the comment: IMHO we should either just close the issue, ir document the bad clock resolution on Windows in the asyncio doc. Yury: asyncio can trigger events earlier than scheduled for performance reasons. See end_time in asyncio core loop. -- _

[issue31539] asyncio.sleep may sleep less time then it should

2017-09-21 Thread Yury Selivanov
Yury Selivanov added the comment: > it's expected that the sleep time may be *more* than asked for, but not less > than. Exactly, and asyncio tries to ensure that. It looks like "time.get_clock_info('monotonic').resolution" lies about monotonic clock resolution on Windows so that might be th

[issue31539] asyncio.sleep may sleep less time then it should

2017-09-21 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- versions: +Python 3.7 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://m

[issue31539] asyncio.sleep may sleep less time then it should

2017-09-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: I don't think the bug is about real time here, rather about minimal sleep time expectations; i.e. it's expected that the sleep time may be *more* than asked for, but not less than. (and I would share that expectation myself) -- __

[issue31539] asyncio.sleep may sleep less time then it should

2017-09-21 Thread STINNER Victor
STINNER Victor added the comment: Technically, asyncii cannot wait exactly 100 ms on Windows. It will be more likely a sleep between 100-15 ms and 100+15 ms. Real time is really a complex topic. CPython with its stop-the-world garbage collector are not designed for real time. -- ___

[issue31539] asyncio.sleep may sleep less time then it should

2017-09-21 Thread Mikhail Gerasimov
Mikhail Gerasimov added the comment: STINNER Victor, thanks for explanation! I don't know if this issue has practical disadvantages, but such behavior seems to be confusing, especially, since it can be reproduced with event_loop.time() and asyncio doc says nothing about resolution - https://do

[issue31539] asyncio.sleep may sleep less time then it should

2017-09-21 Thread STINNER Victor
STINNER Victor added the comment: Clocks is a very complex topic, especially when you care of portability. See my PEP 418. asyncio uses time.monotonic() clock to not be impacted when the system clock ("wall clock") is updated by the administrator or automatically by NTP. On Windows, time.mono

[issue31539] asyncio.sleep may sleep less time then it should

2017-09-21 Thread Antoine Pitrou
Antoine Pitrou added the comment: AFAIR the Windows clock has a 15ms granularity, so I'm not really surprised. In other words, I don't think `asyncio.sleep` sleeps less than expected, but that it's the imprecision of time.time() which gives you that impression. What happens if you replace `tim

[issue31539] asyncio.sleep may sleep less time then it should

2017-09-21 Thread R. David Murray
R. David Murray added the comment: I can't reproduce this on a linux VM with 3.7 tip. I don't currently have a windows instance to test against. -- nosy: +r.david.murray ___ Python tracker __

[issue31539] asyncio.sleep may sleep less time then it should

2017-09-21 Thread Mikhail
New submission from Mikhail: Originally faced here: https://stackoverflow.com/q/46306660/1113207 Simple code to reproduce: import asyncio import time async def main(): while True: asyncio.ensure_future(asyncio.sleep(1)) t0 = time.time()