diff --git a/.github/ISSUE_TEMPLATE.md b/.github/.github/ISSUE_TEMPLATE.md similarity index 100% rename from .github/ISSUE_TEMPLATE.md rename to .github/.github/ISSUE_TEMPLATE.md diff --git a/.github/release_log.py b/.github/.github/release_log.py similarity index 100% rename from .github/release_log.py rename to .github/.github/release_log.py diff --git a/tests/test_uv_timer_when_after_cb.py b/tests/test_uv_timer_when_after_cb.py new file mode 100644 index 00000000..e35bb27f --- /dev/null +++ b/tests/test_uv_timer_when_after_cb.py @@ -0,0 +1,13 @@ +import uvloop +import asyncio + + +async def main(): + loop = asyncio.get_running_loop() + call_ts = loop.time() + 1 + timer = loop.call_at(call_ts, lambda: None) # call any function + await asyncio.sleep(1.1) + assert timer.when() == call_ts + +uvloop.install() +asyncio.run(main(), debug=True) diff --git a/uvloop/cbhandles.pyx b/uvloop/cbhandles.pyx index 6d6a0b04..acdb1005 100644 --- a/uvloop/cbhandles.pyx +++ b/uvloop/cbhandles.pyx @@ -215,7 +215,7 @@ cdef class TimerHandle: self._clear() cdef inline _clear(self): - if self.timer is None: + if self not in self.loop._timers: # check if timer has already been removed return self.callback = None @@ -225,7 +225,7 @@ cdef class TimerHandle: self.loop._timers.remove(self) finally: self.timer._close() - self.timer = None # let the UVTimer handle GC + # self.timer = None # let the UVTimer handle GC this will cause a segfault if .when() is called beyond this point cdef _run(self): if self._cancelled == 1: