forked from goodboy/tractor
				
			Add nooz
							parent
							
								
									16a3321a38
								
							
						
					
					
						commit
						77fc705b1f
					
				| 
						 | 
				
			
			@ -0,0 +1,12 @@
 | 
			
		|||
Fix graceful cancellation of daemon actors
 | 
			
		||||
 | 
			
		||||
Previously, his was a bug where if the soft wait on a sub-process (the
 | 
			
		||||
``await .proc.wait()``) in the reaper task teardown was cancelled we
 | 
			
		||||
would fail over to the hard reaping sequence (meant for culling off any
 | 
			
		||||
potential zombies via system kill signals). The hard reap has a timeout
 | 
			
		||||
of 3s (currently though in theory we could make it shorter?) before
 | 
			
		||||
system signalling kicks in. This means that any daemon actor still
 | 
			
		||||
running during nursery exit would get hard reaped (3s later) instead of
 | 
			
		||||
cancelled via IPC message. Now we catch the ``trio.Cancelled``, call
 | 
			
		||||
``Portal.cancel_actor()`` on the daemon and expect the child to
 | 
			
		||||
self-terminate after the runtime cancels and shuts down the process.
 | 
			
		||||
| 
						 | 
				
			
			@ -298,11 +298,11 @@ async def new_proc(
 | 
			
		|||
                try:
 | 
			
		||||
                    await proc.wait()
 | 
			
		||||
                except trio.Cancelled:
 | 
			
		||||
                    # if cancelled during a soft wait cancel the child
 | 
			
		||||
                    # actor before entering the hard reap
 | 
			
		||||
                    # sequence below. This means we try to do a
 | 
			
		||||
                    # graceful teardown before getting out zombie
 | 
			
		||||
                    # killing tools.
 | 
			
		||||
                    # if cancelled during a soft wait, cancel the child
 | 
			
		||||
                    # actor before entering the hard reap sequence
 | 
			
		||||
                    # below. This means we try to do a graceful teardown
 | 
			
		||||
                    # via sending a cancel message before getting out
 | 
			
		||||
                    # zombie killing tools.
 | 
			
		||||
                    with trio.CancelScope(shield=True):
 | 
			
		||||
                        await portal.cancel_actor()
 | 
			
		||||
                    raise
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue