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:
 | 
					                try:
 | 
				
			||||||
                    await proc.wait()
 | 
					                    await proc.wait()
 | 
				
			||||||
                except trio.Cancelled:
 | 
					                except trio.Cancelled:
 | 
				
			||||||
                    # if cancelled during a soft wait cancel the child
 | 
					                    # if cancelled during a soft wait, cancel the child
 | 
				
			||||||
                    # actor before entering the hard reap
 | 
					                    # actor before entering the hard reap sequence
 | 
				
			||||||
                    # sequence below. This means we try to do a
 | 
					                    # below. This means we try to do a graceful teardown
 | 
				
			||||||
                    # graceful teardown before getting out zombie
 | 
					                    # via sending a cancel message before getting out
 | 
				
			||||||
                    # killing tools.
 | 
					                    # zombie killing tools.
 | 
				
			||||||
                    with trio.CancelScope(shield=True):
 | 
					                    with trio.CancelScope(shield=True):
 | 
				
			||||||
                        await portal.cancel_actor()
 | 
					                        await portal.cancel_actor()
 | 
				
			||||||
                    raise
 | 
					                    raise
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue