Saturday, June 1, 2013

Python Tip - Create and detach a child process

Create and detach a child process

Use the following code to create and subsequently detach a child process

  DETACHED_PROCESS = 0x00000008
  pid = subprocess.Popen([sys.executable, "longtask.py"],
                         creationflags=DETACHED_PROCESS)

  pid.poll()  # Returns: None if child still active
              #          returncode otherwise 


In Sym, a complex component will be made up of a parent process and related child processes. 

See Also


1 comment:

  1. This only works on the Windows operating system.

    ReplyDelete