File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ def set(self, value=None):
4646 self ._exception = None
4747 for callback in self ._callbacks :
4848 self ._handler .completion_queue .put (
49- lambda : callback ( self )
49+ functools . partial ( callback , self )
5050 )
5151 self ._condition .notify_all ()
5252
@@ -56,7 +56,7 @@ def set_exception(self, exception):
5656 self ._exception = exception
5757 for callback in self ._callbacks :
5858 self ._handler .completion_queue .put (
59- lambda : callback ( self )
59+ functools . partial ( callback , self )
6060 )
6161 self ._condition .notify_all ()
6262
@@ -103,7 +103,7 @@ def rawlink(self, callback):
103103 # Are we already set? Dispatch it now
104104 if self .ready ():
105105 self ._handler .completion_queue .put (
106- lambda : callback ( self )
106+ functools . partial ( callback , self )
107107 )
108108 return
109109
Original file line number Diff line number Diff line change @@ -376,3 +376,19 @@ def regular_function():
376376 assert regular_function () == 'hello'
377377 assert mock_handler .completion_queue .put .called
378378 assert async_result .get () == 'hello'
379+
380+ def test_multiple_callbacks (self ):
381+ mockback1 = mock .Mock (name = 'mockback1' )
382+ mockback2 = mock .Mock (name = 'mockback2' )
383+ handler = self ._makeHandler ()
384+ handler .start ()
385+
386+ async_result = self ._makeOne (handler )
387+ async_result .rawlink (mockback1 )
388+ async_result .rawlink (mockback2 )
389+ async_result .set ('howdy' )
390+ async_result .wait ()
391+ handler .stop ()
392+
393+ mockback2 .assert_called_once_with (async_result )
394+ mockback1 .assert_called_once_with (async_result )
You can’t perform that action at this time.
0 commit comments