SC2: don't close all SC2 instances when one quits (#3507)
This commit is contained in:
		
							parent
							
								
									87d24eb38a
								
							
						
					
					
						commit
						e755f1a0b5
					
				| 
						 | 
					@ -28,6 +28,11 @@ class kill_switch:
 | 
				
			||||||
        logger.debug("kill_switch: Add switch")
 | 
					        logger.debug("kill_switch: Add switch")
 | 
				
			||||||
        cls._to_kill.append(value)
 | 
					        cls._to_kill.append(value)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @classmethod
 | 
				
			||||||
 | 
					    def kill(cls, value):
 | 
				
			||||||
 | 
					        logger.info(f"kill_switch: Process cleanup for 1 process")
 | 
				
			||||||
 | 
					        value._clean(verbose=False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @classmethod
 | 
					    @classmethod
 | 
				
			||||||
    def kill_all(cls):
 | 
					    def kill_all(cls):
 | 
				
			||||||
        logger.info(f"kill_switch: Process cleanup for {len(cls._to_kill)} processes")
 | 
					        logger.info(f"kill_switch: Process cleanup for {len(cls._to_kill)} processes")
 | 
				
			||||||
| 
						 | 
					@ -116,7 +121,7 @@ class SC2Process:
 | 
				
			||||||
    async def __aexit__(self, *args):
 | 
					    async def __aexit__(self, *args):
 | 
				
			||||||
        logger.exception("async exit")
 | 
					        logger.exception("async exit")
 | 
				
			||||||
        await self._close_connection()
 | 
					        await self._close_connection()
 | 
				
			||||||
        kill_switch.kill_all()
 | 
					        kill_switch.kill(self)
 | 
				
			||||||
        signal.signal(signal.SIGINT, signal.SIG_DFL)
 | 
					        signal.signal(signal.SIGINT, signal.SIG_DFL)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue