Kaydet (Commit) d07db96a authored tarafından Serhiy Storchaka's avatar Serhiy Storchaka

Issue #16640: Run less code under a lock in sched module.

üst 1147f824
...@@ -71,8 +71,8 @@ class scheduler: ...@@ -71,8 +71,8 @@ class scheduler:
""" """
if kwargs is _sentinel: if kwargs is _sentinel:
kwargs = {} kwargs = {}
with self._lock:
event = Event(time, priority, action, argument, kwargs) event = Event(time, priority, action, argument, kwargs)
with self._lock:
heapq.heappush(self._queue, event) heapq.heappush(self._queue, event)
return event # The ID return event # The ID
...@@ -82,7 +82,6 @@ class scheduler: ...@@ -82,7 +82,6 @@ class scheduler:
This is actually the more commonly used interface. This is actually the more commonly used interface.
""" """
with self._lock:
time = self.timefunc() + delay time = self.timefunc() + delay
return self.enterabs(time, priority, action, argument, kwargs) return self.enterabs(time, priority, action, argument, kwargs)
......
...@@ -200,6 +200,8 @@ Core and Builtins ...@@ -200,6 +200,8 @@ Core and Builtins
Library Library
------- -------
- Issue #16640: Run less code under a lock in sched module.
- Issue #16165: Fix sched.scheduler.run() method was block a scheduler for - Issue #16165: Fix sched.scheduler.run() method was block a scheduler for
other threads. other threads.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment