Lines 1599-1605
Link Here
|
1599 |
""" |
1599 |
""" |
1600 |
|
1600 |
|
1601 |
__slots__ = ("background", "cancelled", "returncode") + \ |
1601 |
__slots__ = ("background", "cancelled", "returncode") + \ |
1602 |
("_exit_listeners", "_start_listeners") |
1602 |
("_exit_listeners", "_exit_listener_stack", "_start_listeners") |
1603 |
|
1603 |
|
1604 |
def start(self): |
1604 |
def start(self): |
1605 |
""" |
1605 |
""" |
Lines 1665-1670
Link Here
|
1665 |
|
1665 |
|
1666 |
def removeExitListener(self, f): |
1666 |
def removeExitListener(self, f): |
1667 |
if self._exit_listeners is None: |
1667 |
if self._exit_listeners is None: |
|
|
1668 |
if self._exit_listener_stack is not None: |
1669 |
self._exit_listener_stack.remove(f) |
1668 |
return |
1670 |
return |
1669 |
self._exit_listeners.remove(f) |
1671 |
self._exit_listeners.remove(f) |
1670 |
|
1672 |
|
Lines 1680-1691
Link Here
|
1680 |
|
1682 |
|
1681 |
# This prevents recursion, in case one of the |
1683 |
# This prevents recursion, in case one of the |
1682 |
# exit handlers triggers this method again by |
1684 |
# exit handlers triggers this method again by |
1683 |
# calling wait(). |
1685 |
# calling wait(). Use a stack that gives |
1684 |
exit_listeners = self._exit_listeners |
1686 |
# removeExitListener() an opportunity to consume |
|
|
1687 |
# listeners from the stack, before they can get |
1688 |
# called below. This is necessary because a call |
1689 |
# to one exit listener may result in a call to |
1690 |
# removeExitListener() for another listener on |
1691 |
# the stack. That listener needs to be removed |
1692 |
# from the stack since it would be inconsistent |
1693 |
# to call it after it has been been passed into |
1694 |
# removeExitListener(). |
1695 |
self._exit_listener_stack = self._exit_listeners |
1685 |
self._exit_listeners = None |
1696 |
self._exit_listeners = None |
1686 |
|
1697 |
|
1687 |
for f in exit_listeners: |
1698 |
self._exit_listener_stack.reverse() |
1688 |
f(self) |
1699 |
while self._exit_listener_stack: |
|
|
1700 |
self._exit_listener_stack.pop()(self) |
1689 |
|
1701 |
|
1690 |
class PipeReader(AsynchronousTask): |
1702 |
class PipeReader(AsynchronousTask): |
1691 |
|
1703 |
|