forked from goodboy/tractor
				
			Ack our inability to hard kill sub-procs
							parent
							
								
									fc2cb610b9
								
							
						
					
					
						commit
						29ed065dc4
					
				| 
						 | 
					@ -278,7 +278,8 @@ class Portal:
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            # send cancel cmd - might not get response
 | 
					            # send cancel cmd - might not get response
 | 
				
			||||||
            # XXX: sure would be nice to make this work with a proper shield
 | 
					            # XXX: sure would be nice to make this work with a proper shield
 | 
				
			||||||
            # with trio.CancelScope(shield=True):
 | 
					            # with trio.CancelScope() as cancel_scope:
 | 
				
			||||||
 | 
					            # with trio.CancelScope(shield=True) as cancel_scope:
 | 
				
			||||||
            with trio.move_on_after(0.5) as cancel_scope:
 | 
					            with trio.move_on_after(0.5) as cancel_scope:
 | 
				
			||||||
                cancel_scope.shield = True
 | 
					                cancel_scope.shield = True
 | 
				
			||||||
                await self.run('self', 'cancel')
 | 
					                await self.run('self', 'cancel')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -188,8 +188,17 @@ async def spawn_subactor(
 | 
				
			||||||
        # the outer scope since no actor zombies are
 | 
					        # the outer scope since no actor zombies are
 | 
				
			||||||
        # ever allowed. This ``__aexit__()`` also shields
 | 
					        # ever allowed. This ``__aexit__()`` also shields
 | 
				
			||||||
        # internally.
 | 
					        # internally.
 | 
				
			||||||
 | 
					        log.debug(f"Attempting to kill {proc}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # NOTE: this timeout effectively does nothing right now since
 | 
				
			||||||
 | 
					        # we are shielding the ``.wait()`` inside ``new_proc()`` which
 | 
				
			||||||
 | 
					        # will pretty much never release until the process exits.
 | 
				
			||||||
 | 
					        with trio.move_on_after(3) as cs:
 | 
				
			||||||
            async with proc:
 | 
					            async with proc:
 | 
				
			||||||
                log.debug(f"Terminating {proc}")
 | 
					                log.debug(f"Terminating {proc}")
 | 
				
			||||||
 | 
					        if cs.cancelled_caught:
 | 
				
			||||||
 | 
					            log.critical(f"HARD KILLING {proc}")
 | 
				
			||||||
 | 
					            proc.kill()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
async def new_proc(
 | 
					async def new_proc(
 | 
				
			||||||
| 
						 | 
					@ -354,6 +363,8 @@ async def new_proc(
 | 
				
			||||||
                await proc_waiter(proc)
 | 
					                await proc_waiter(proc)
 | 
				
			||||||
            proc.join()
 | 
					            proc.join()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # This is again common logic for all backends:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        log.debug(f"Joined {proc}")
 | 
					        log.debug(f"Joined {proc}")
 | 
				
			||||||
        # pop child entry to indicate we are no longer managing this subactor
 | 
					        # pop child entry to indicate we are no longer managing this subactor
 | 
				
			||||||
        subactor, proc, portal = actor_nursery._children.pop(subactor.uid)
 | 
					        subactor, proc, portal = actor_nursery._children.pop(subactor.uid)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue