Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, I agree that you need to put a flag in your directories indicating that a directory is <em>being</em> processed. The master script should be the only one to set the flag, or you will risk race conditions (two worker scripts taking the same directory at the same time). You can use the same file; the master script creates it empty (meaning "in progress") and the worker script writes 1B in it (meaning "done"). That way, the master script only has to check the existence of the flag.</p> <p>Back to your question:</p> <ul> <li><p>you can indeed make your worker script into a standalone program, and call it via the <code>subprocess</code> module;</p></li> <li><p>you can make it a thread (with the <code>threading</code> module [2]), which is somewhat easier to code; this may be inefficient because of the <a href="http://docs.python.org/library/threading.html" rel="nofollow">GIL</a>, but if your worker script is highly IO-bound, it should not be too much of a problem;</p></li> <li><p>if you are using Python 3, you may want to look at the <code>multiprocessing</code> module [3]<br> which I never used but seems to mix the usability of threading without being vulnerable to the GIL; it seems that it is not completely portable though.</p></li> </ul> <p>Hope this helps</p> <ul> <li>[1] <code>http://docs.python.org/library/subprocess.html</code></li> <li>[2] <code>http://docs.python.org/library/threading.html</code></li> <li>[3] <code>http://docs.python.org/dev/library/multiprocessing.html</code></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload