1 |
commit: abf4b7abcdc53bbbd86eb6f79d45417b54ed64d2 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Apr 29 22:12:13 2018 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Apr 29 22:18:28 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=abf4b7ab |
7 |
|
8 |
AsyncScheduler: call_later asyncio compat (bug 591760) |
9 |
|
10 |
Use call_later for asyncio compatibility. Also remove the |
11 |
timeout_add method from SchedulerInterface, since there are |
12 |
no more consumers. |
13 |
|
14 |
Bug: https://bugs.gentoo.org/591760 |
15 |
|
16 |
pym/portage/util/_async/AsyncScheduler.py | 9 +++++++-- |
17 |
pym/portage/util/_async/SchedulerInterface.py | 1 - |
18 |
2 files changed, 7 insertions(+), 3 deletions(-) |
19 |
|
20 |
diff --git a/pym/portage/util/_async/AsyncScheduler.py b/pym/portage/util/_async/AsyncScheduler.py |
21 |
index 90e803eba..c6b523eaa 100644 |
22 |
--- a/pym/portage/util/_async/AsyncScheduler.py |
23 |
+++ b/pym/portage/util/_async/AsyncScheduler.py |
24 |
@@ -65,6 +65,11 @@ class AsyncScheduler(AsynchronousTask, PollScheduler): |
25 |
task.addExitListener(self._task_exit) |
26 |
task.start() |
27 |
|
28 |
+ if self._loadavg_check_id is not None: |
29 |
+ self._loadavg_check_id.cancel() |
30 |
+ self._loadavg_check_id = self._event_loop.call_later( |
31 |
+ self._loadavg_latency, self._schedule) |
32 |
+ |
33 |
# Triggers cleanup and exit listeners if there's nothing left to do. |
34 |
self.poll() |
35 |
|
36 |
@@ -80,14 +85,14 @@ class AsyncScheduler(AsynchronousTask, PollScheduler): |
37 |
(self._max_jobs is True or self._max_jobs > 1): |
38 |
# We have to schedule periodically, in case the load |
39 |
# average has changed since the last call. |
40 |
- self._loadavg_check_id = self._event_loop.timeout_add( |
41 |
+ self._loadavg_check_id = self._event_loop.call_later( |
42 |
self._loadavg_latency, self._schedule) |
43 |
self._schedule() |
44 |
|
45 |
def _cleanup(self): |
46 |
super(AsyncScheduler, self)._cleanup() |
47 |
if self._loadavg_check_id is not None: |
48 |
- self._event_loop.source_remove(self._loadavg_check_id) |
49 |
+ self._loadavg_check_id.cancel() |
50 |
self._loadavg_check_id = None |
51 |
|
52 |
def _async_wait(self): |
53 |
|
54 |
diff --git a/pym/portage/util/_async/SchedulerInterface.py b/pym/portage/util/_async/SchedulerInterface.py |
55 |
index ff39bc587..56b844616 100644 |
56 |
--- a/pym/portage/util/_async/SchedulerInterface.py |
57 |
+++ b/pym/portage/util/_async/SchedulerInterface.py |
58 |
@@ -15,7 +15,6 @@ class SchedulerInterface(SlotObject): |
59 |
"IO_NVAL", "IO_OUT", "IO_PRI", |
60 |
"io_add_watch", |
61 |
"source_remove", |
62 |
- "timeout_add", |
63 |
|
64 |
"add_reader", |
65 |
"add_writer", |