aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/PySide6/QtAsyncio/events.py
diff options
context:
space:
mode:
authorAdrian Herrmann <adrian.herrmann@qt.io>2023-09-11 20:20:35 +0200
committerAdrian Herrmann <adrian.herrmann@qt.io>2023-09-12 11:55:30 +0200
commit971c5944415cd557112ff046c4b0c41e8b0d5b05 (patch)
treefc1df26b5ced26c2ffd0fe574e296c298afa8f93 /sources/pyside6/PySide6/QtAsyncio/events.py
parent0d500d003d4c8f199aaae3cfa830227261b48ed0 (diff)
QtAsyncio: Fix time unit
loop.time() needs to return the time in seconds as a float, not in milliseconds as an int. Task-number: PYSIDE-769 Change-Id: Iac123132b49d3954abda8545d0830f1837a27c48 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6/PySide6/QtAsyncio/events.py')
-rw-r--r--sources/pyside6/PySide6/QtAsyncio/events.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/sources/pyside6/PySide6/QtAsyncio/events.py b/sources/pyside6/PySide6/QtAsyncio/events.py
index ebae09a73..94930082d 100644
--- a/sources/pyside6/PySide6/QtAsyncio/events.py
+++ b/sources/pyside6/PySide6/QtAsyncio/events.py
@@ -202,7 +202,7 @@ class QAsyncioEventLoop(asyncio.BaseEventLoop):
context: typing.Optional[contextvars.Context] = None) -> "QAsyncioHandle":
if not isinstance(delay, (int, float)):
raise TypeError("delay must be an int or float")
- return self.call_at(self.time() + delay * 1000, callback, *args,
+ return self.call_at(self.time() + delay, callback, *args,
context=context)
def call_at(self, when: typing.Union[int, float], # type: ignore[override]
@@ -212,10 +212,10 @@ class QAsyncioEventLoop(asyncio.BaseEventLoop):
raise TypeError("when must be an int or float")
if self.is_closed():
raise RuntimeError("Event loop is closed")
- return QAsyncioTimerHandle(int(when), callback, args, self, context)
+ return QAsyncioTimerHandle(when, callback, args, self, context)
- def time(self) -> int:
- return QDateTime.currentMSecsSinceEpoch()
+ def time(self) -> float:
+ return QDateTime.currentMSecsSinceEpoch() / 1000
# Creating Futures and Tasks
@@ -494,12 +494,12 @@ class QAsyncioHandle():
class QAsyncioTimerHandle(QAsyncioHandle):
- def __init__(self, when: int, callback: typing.Callable, args: typing.Tuple,
+ def __init__(self, when: float, callback: typing.Callable, args: typing.Tuple,
loop: QAsyncioEventLoop, context: typing.Optional[contextvars.Context]) -> None:
super().__init__(callback, args, loop, context)
self._when = when
- self._timeout = max(self._when - self._loop.time(), 0)
+ self._timeout = int(max(self._when - self._loop.time(), 0) * 1000)
super()._start()
@@ -508,5 +508,5 @@ class QAsyncioTimerHandle(QAsyncioHandle):
def _start(self) -> None:
pass
- def when(self) -> int:
+ def when(self) -> float:
return self._when