I have written a python code that will copy a file from its source directory, paste it into a new directory and parse it into an XML file. I got to know certain modules in python such as subprocess, multiprocess, threading, etc. which will help me frequently perform the aforementioned tasks in the background. But I don't know which is the appropriate one. Please help!

1 Answer 1


My go-to solution for this is this amazing article: in short, it uses some permission management to allow you/the computer to use the Python interpreter as a command, which can then be executed by nohup, which is the command which executes what you are looking for.

If you would like a solution based in Python (meaning no OS dependancy), use the subprocess module. It is the easiest way to do it in my opinion, especially if you are loading large amounts of data into RAM or, as in your case, you are opening files, in which case multiprocessing/threading can get cumbersome and risk corrupting your files. Essentially, as explained here in the Python docs, you can control the input/output method of your program, allowing you to, in a way, emulate your own shell. Note that will need to momentarily run the command to call this, but if you set it up right you can emulate the nohup command, provided the code you already have is being called from a separate file.

  • I will try this for sure. Thank you for such detailed answer! I'll let you know for sure if it works. Jun 14, 2019 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.