Python subprocess background nohup

broken image
broken image
broken image

Under Fabric 1's local(., capture=False) (the default behavior), it's possible to do local('shell command &') to background a shell command in a way that's completely disassociated from the parent Python process.

broken image

Plus the normal adage that if one set of users is doing an unusual thing, there will be others, and I'd rather the software cope gracefully with this instead of surprising users. Roughly analogous to sourcing a shell script that uses & a bunch.Īn obvious counter-argument to this case is 'use real process supervision' - but I've determined that my local users have a good-enough need for true 'orphaned children' subprocesses that this falls under a legit, if corner, use case for a toolset like Invoke. The tl dr use case is to have a (long running in their case, but that's actually orthogonal) Python process using Fabric 1 or Invoke to kick off subprocesses that then live outside the control of the main program. Kind of an odd duck, but this came out of an internal need at my dayjob and I think it's worth examining for public use.

broken image