mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 21:51:50 +00:00 
			
		
		
		
	bpo-35621: Support running subprocesses in asyncio when loop is executed in non-main thread (GH-14344)
This commit is contained in:
		
							parent
							
								
									5cbbbd73a6
								
							
						
					
					
						commit
						0d671c04c3
					
				
					 7 changed files with 378 additions and 72 deletions
				
			
		|  | @ -1,5 +1,6 @@ | |||
| """Utilities shared by tests.""" | ||||
| 
 | ||||
| import asyncio | ||||
| import collections | ||||
| import contextlib | ||||
| import io | ||||
|  | @ -512,6 +513,18 @@ def close_loop(loop): | |||
|         if executor is not None: | ||||
|             executor.shutdown(wait=True) | ||||
|         loop.close() | ||||
|         policy = support.maybe_get_event_loop_policy() | ||||
|         if policy is not None: | ||||
|             try: | ||||
|                 watcher = policy.get_child_watcher() | ||||
|             except NotImplementedError: | ||||
|                 # watcher is not implemented by EventLoopPolicy, e.g. Windows | ||||
|                 pass | ||||
|             else: | ||||
|                 if isinstance(watcher, asyncio.ThreadedChildWatcher): | ||||
|                     threads = list(watcher._threads.values()) | ||||
|                     for thread in threads: | ||||
|                         thread.join() | ||||
| 
 | ||||
|     def set_event_loop(self, loop, *, cleanup=True): | ||||
|         assert loop is not None | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andrew Svetlov
						Andrew Svetlov