Lines 4-9
Link Here
|
4 |
import signal |
4 |
import signal |
5 |
|
5 |
|
6 |
from portage import os |
6 |
from portage import os |
|
|
7 |
from portage.util.futures import asyncio |
7 |
from portage.util.SlotObject import SlotObject |
8 |
from portage.util.SlotObject import SlotObject |
8 |
|
9 |
|
9 |
class AsynchronousTask(SlotObject): |
10 |
class AsynchronousTask(SlotObject): |
Lines 17-24
class AsynchronousTask(SlotObject):
Link Here
|
17 |
""" |
18 |
""" |
18 |
|
19 |
|
19 |
__slots__ = ("background", "cancelled", "returncode", "scheduler") + \ |
20 |
__slots__ = ("background", "cancelled", "returncode", "scheduler") + \ |
20 |
("_exit_listeners", "_exit_listener_stack", "_start_listeners", |
21 |
("_exit_listeners", "_exit_listener_stack", "_start_listeners") |
21 |
"_waiting") |
|
|
22 |
|
22 |
|
23 |
_cancelled_returncode = - signal.SIGINT |
23 |
_cancelled_returncode = - signal.SIGINT |
24 |
|
24 |
|
Lines 71-82
class AsynchronousTask(SlotObject):
Link Here
|
71 |
Deprecated. Use async_wait() instead. |
71 |
Deprecated. Use async_wait() instead. |
72 |
""" |
72 |
""" |
73 |
if self.returncode is None: |
73 |
if self.returncode is None: |
74 |
if not self._waiting: |
74 |
if self.scheduler.is_running(): |
75 |
self._waiting = True |
75 |
raise asyncio.InvalidStateError('Result is not ready.') |
76 |
try: |
76 |
self.scheduler.run_until_complete(self.async_wait()) |
77 |
self._wait() |
|
|
78 |
finally: |
79 |
self._waiting = False |
80 |
self._wait_hook() |
77 |
self._wait_hook() |
81 |
return self.returncode |
78 |
return self.returncode |
82 |
|
79 |
|
Lines 91-96
class AsynchronousTask(SlotObject):
Link Here
|
91 |
loop recursion (or stack overflow) that synchronous calling of |
88 |
loop recursion (or stack overflow) that synchronous calling of |
92 |
exit listeners can cause. This method is thread-safe. |
89 |
exit listeners can cause. This method is thread-safe. |
93 |
""" |
90 |
""" |
|
|
91 |
if self.returncode is None: |
92 |
raise asyncio.InvalidStateError('Result is not ready.') |
94 |
self.scheduler.idle_add(self._async_wait_cb) |
93 |
self.scheduler.idle_add(self._async_wait_cb) |
95 |
|
94 |
|
96 |
def _async_wait_cb(self): |
95 |
def _async_wait_cb(self): |
97 |
- |
|
|