Compare commits
	
		
			1 Commits 
		
	
	
		
			71cf9e7bd3
			...
			a69bc00593
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | a69bc00593 | 
|  | @ -579,14 +579,12 @@ def run_trio_task_in_future( | |||
|     cancel_scope = trio.CancelScope() | ||||
|     finished: bool = False | ||||
| 
 | ||||
|     # monkey-patch the future's `.cancel()` meth to | ||||
|     # allow cancellation relay to `trio`-task. | ||||
|     cancel_message: str|None = None | ||||
|     # Monkeypatch the returned future's cancel() method to forward | ||||
|     # cancellation to the Trio task | ||||
|     cancel_message = None | ||||
|     orig_cancel = result_future.cancel | ||||
| 
 | ||||
|     def wrapped_cancel( | ||||
|         msg: str|None = None, | ||||
|     ): | ||||
|     def wrapped_cancel(msg=None): | ||||
|         nonlocal cancel_message | ||||
|         if finished: | ||||
|             # We're being called back after the task completed | ||||
|  | @ -607,6 +605,7 @@ def run_trio_task_in_future( | |||
|         return True | ||||
| 
 | ||||
|     result_future.cancel = wrapped_cancel | ||||
|     # End of monkeypatching | ||||
| 
 | ||||
|     async def trio_task() -> None: | ||||
|         nonlocal finished | ||||
|  | @ -626,7 +625,7 @@ def run_trio_task_in_future( | |||
|                 result_future.set_result(result) | ||||
| 
 | ||||
|         except BaseException as exc: | ||||
|             # the result future gets all the non-Cancelled | ||||
|             # The result future gets all the non-Cancelled | ||||
|             # exceptions.  Any Cancelled need to keep propagating | ||||
|             # out of this stack frame in order to reach the cancel | ||||
|             # scope for which they're intended. | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue