Search code examples
pythonmultithreadingspawn

Spawning a process


What exactly does the line

spawn a process that would run it autonomously

means, please explain.

Language Python

Server Linux

An example will be better for understanding.


Solution

  • It means to create a subprocess that does something ("runs it") independently of your main python process. You can read up on the Python subprocess module for details. Without knowing your exact needs, it's hard to suggest what is specifically best for you, but here's an extremely simple example:

    import subprocess
    
    subprocess.call("/bin/date")
    

    This will run /bin/date, and the output will go to standard error.