I thought it would be nice for you to know what’s going on internally, but if you feel confused, rest assured that you don’t need this knowledge to do what you want: running an external command with the Python subprocess module. This wrapper is the function run() from the subprocess package and that’s what we’ll use in this article. Thanks to the wrapper, running an external command comes down to calling a function. We can go the low-level way and do much of this ourselves using the Python subprocess module, but luckily, Python also offers a wrapper that will take care of all the nitty-gritty details, and do so safely too. That copy, in turn, replaces itself with another process: the process you were looking to execute. First, the process forks itself, creating a copy. We can utilize this same technique to start another process, though. This can be useful if you want to parallelize your code and utilize multiple CPUs on your machine. The process forks itself, meaning a new copy of the process is created and started. What happens internally (inside the OS kernel) is what’s called a fork. A parent process spawning two sub-processes
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |