Changeset 3665
- Timestamp:
- 17/11/08 00:42:38 (8 weeks ago)
- Files:
-
- 1 modified
-
trunk/base/src/notifier/async.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/base/src/notifier/async.py
r3658 r3665 469 469 import main 470 470 from thread import is_mainthread 471 472 # Connect a dummy handler to ourselves. This is a bit kludgy, but 473 # solves a particular problem with InProgress(Any|All), which don't 474 # actually finish unless something wants to know. Normally, without 475 # wait, we are yielded to the coroutine wrapper which implicitly 476 # connects to us. Here, with wait(), in a sense we want to know when 477 # self finishes. 478 dummy = lambda *args, **kwargs: None 479 self.connect(dummy) 480 471 481 if is_mainthread(): 472 482 # We're waiting in the main thread, so we must keep the mainloop … … 486 496 487 497 if not self.is_finished(): 498 self.disconnect(dummy) 488 499 raise TimeoutException 489 500 … … 565 576 building state machines using coroutines. 566 577 567 The InProgressAny object then finishes with a 2-tuple, whose first 568 element is the index (offset from 0) of the InProgress that finished, 569 and the second element is the result the InProgress was finished with. 570 """ 571 def __init__(self, *objects): 578 If pass_index is True, the InProgressAny object then finishes with a 579 2-tuple, whose first element is the index (offset from 0) of the InProgress 580 that finished, and the second element is the result the InProgress was 581 finished with. 582 583 If pass_index is False, the InProgressAny is finished with just the result 584 and not the index. 585 """ 586 def __init__(self, *objects, **kwargs): 572 587 super(InProgressAny, self).__init__() 588 self._pass_index = kwargs.get('pass_index', True) 573 589 # Generate InProgress objects for anything that was passed. 574 590 self._objects = [ inprogress(o) for o in objects ] … … 630 646 constructor have finished. 631 647 """ 632 super(InProgressAny, self).finish((result, args)) 648 if self._pass_index: 649 data = (result, args) 650 else: 651 data = args 652 super(InProgressAny, self).finish(data) 653 633 654 # We're done with the underlying IP objects so unref them. In the 634 655 # case of InProgressCallbacks connected weakly to signals (which
