summaryrefslogtreecommitdiffstats
path: root/pym/_emerge/AsynchronousTask.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-12-30 17:01:59 -0800
committerZac Medico <zmedico@gentoo.org>2012-12-30 17:04:27 -0800
commita3100be184ba1cac2f672f0a1cadcf01690c6d3f (patch)
tree53fa53cd147e24c7230daa71ddd7821fd6803108 /pym/_emerge/AsynchronousTask.py
parent7ebb2f54877edb28621c33e380f8777b1b1dc201 (diff)
downloadportage-a3100be184ba1cac2f672f0a1cadcf01690c6d3f.tar.gz
portage-a3100be184ba1cac2f672f0a1cadcf01690c6d3f.tar.bz2
portage-a3100be184ba1cac2f672f0a1cadcf01690c6d3f.zip
AsynchronousTask: add _async_wait method
For cases where _start returns synchronously, this method is a convenient way to trigger an asynchronous call to self.wait() (in order to notify exit listeners), avoiding excessive event loop recursion (or stack overflow) that synchronous calling of exit listeners can cause.
Diffstat (limited to 'pym/_emerge/AsynchronousTask.py')
-rw-r--r--pym/_emerge/AsynchronousTask.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/pym/_emerge/AsynchronousTask.py b/pym/_emerge/AsynchronousTask.py
index 7a193ce7d..b540575d8 100644
--- a/pym/_emerge/AsynchronousTask.py
+++ b/pym/_emerge/AsynchronousTask.py
@@ -60,6 +60,20 @@ class AsynchronousTask(SlotObject):
def _wait(self):
return self.returncode
+ def _async_wait(self):
+ """
+ For cases where _start exits synchronously, this method is a
+ convenient way to trigger an asynchronous call to self.wait()
+ (in order to notify exit listeners), avoiding excessive event
+ loop recursion (or stack overflow) that synchronous calling of
+ exit listeners can cause.
+ """
+ self.scheduler.idle_add(self._async_wait_cb)
+
+ def _async_wait_cb(self):
+ self.wait()
+ return False
+
def cancel(self):
"""
Cancel the task, but do not wait for exit status. If asynchronous exit