Skip to content

Instantly share code, notes, and snippets.

@Ceasar
Last active December 13, 2015 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ceasar/4974658 to your computer and use it in GitHub Desktop.
Save Ceasar/4974658 to your computer and use it in GitHub Desktop.
Extend fabric.api.local to run commands in the background.
import subprocess
import fabric
def local(command, capture=False, shell=False, bg=False):
if bg:
if capture:
with open("/dev/null", "w") as f:
subprocess.Popen(command.split(), stdout=f, shell=shell)
else:
subprocess.Popen(command.split(), shell=shell)
else:
return fabric.api.local(command, capture, shell)
@Ceasar
Copy link
Author

Ceasar commented May 11, 2013

Worth preserving for posterity, but generally, this should be avoided. For web apps at least, Procfiles are preferable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment