Package _emerge :: Module AsynchronousTask :: Class AsynchronousTask
[hide private]

Class AsynchronousTask

source code

                        object --+    
                                 |    
portage.util.SlotObject.SlotObject --+
                                     |
                                    AsynchronousTask
Known Subclasses:

Subclasses override _wait() and _poll() so that calls to public methods can be wrapped for implementing hooks such as exit listener notification.

Sublasses should call self.wait() to notify exit listeners after the task is complete and self.returncode has been set.

Instance Methods [hide private]
 
start(self)
Start an asynchronous task and then return as soon as possible.
source code
 
_start(self) source code
 
isAlive(self) source code
 
poll(self) source code
 
_poll(self) source code
 
wait(self) source code
 
_wait(self) source code
 
_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.
source code
 
_async_wait_cb(self) source code
 
cancel(self)
Cancel the task, but do not wait for exit status.
source code
 
_cancel(self)
Subclasses should implement this, as a template method to be called by AsynchronousTask.cancel().
source code
 
_was_cancelled(self)
If cancelled, set returncode if necessary and return True.
source code
 
addStartListener(self, f)
The function will be called with one argument, a reference to self.
source code
 
removeStartListener(self, f) source code
 
_start_hook(self) source code
 
addExitListener(self, f)
The function will be called with one argument, a reference to self.
source code
 
removeExitListener(self, f) source code
 
_wait_hook(self)
Call this method after the task completes, just before returning the returncode from wait() or poll().
source code

Inherited from portage.util.SlotObject.SlotObject: __init__, copy

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  _cancelled_returncode = -2
Properties [hide private]
  _exit_listener_stack
  _exit_listeners
  _start_listeners
  _waiting
  background
  cancelled
  returncode

Inherited from object: __class__

Method Details [hide private]

_async_wait(self)

source code 

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. This method is thread-safe.

cancel(self)

source code 

Cancel the task, but do not wait for exit status. If asynchronous exit notification is desired, then use addExitListener to add a listener before calling this method. NOTE: Synchronous waiting for status is not supported, since it would be vulnerable to hitting the recursion limit when a large number of tasks need to be terminated simultaneously, like in bug #402335.

_was_cancelled(self)

source code 

If cancelled, set returncode if necessary and return True. Otherwise, return False.

_wait_hook(self)

source code 

Call this method after the task completes, just before returning the returncode from wait() or poll(). This hook is used to trigger exit listeners when the returncode first becomes available.