goodboy / tractor

A distributed, structured concurrent runtime for Python (and friends)
GNU Affero General Public License v3.0
258 stars 12 forks source link

Debug lock blocking #337

Closed goodboy closed 1 year ago

goodboy commented 1 year ago

Pulled out from #333.

Provides a (decent) solution to the problem of a sub-actor (of the root) who loses IPC connectivity but still tries to acquire the stdstreams / TTY lock. This failure mode can result in a deadlock where the root thinks the child is in debug while the child is waiting to be cancelled and because of our debug mode SIGINT override handler, the root and child never tear down on ctl-c from the user..


This patch solves that by taking a simple approach: whenever the root actor detects that some peer (who presumably is some child-ish) has no more working IPC (channel) connections, will stick the sub's Actor.uid on a new ._debug.Lock._blocked list such that the actor is furthermore blocked from acquiring the lock and will be rejected from such with a ContextCancelled.


Additionally included here is some test fixes which accommodate this change, mainly some of the debugger tests terminating earlier then previous due to the block list preventing recurrent locks from a nested child who's parent has already been cancelled and thus IPC disconnected.

Also, is a couple tweaks to the asyncio test suite discovered in the #333 tinkerings.