title: What is Hudson doing with my Python script?
body: <p>I am developing a Python script (here after script) that searches through large log files for a search string. In normal use, it is called from a Hudson front end. </p>
  
  <p><strong>About the Hudson interface:</strong><br>
  The Hudson job creates a temporary batch file on a connected virtual machine (VM) that calls the script and passes it some parameters. We have had hundreds of successful instances using this setup, but something is now creating an error.</p>
  
  <p><strong>About the script:</strong><br>
  The log files are contained in dozens of compressed <em>.tgz</em> files. My script searches each log in each <em>.tgz</em> file.<br>
  One of the command line args that my script accepts is a <em>True/False</em> parameter called <strong>PROCESS_IN_PARALLEL</strong>. If <strong>PROCESS_IN_PARALLEL</strong> is set to <em>True</em>, then each <em>.tgz</em> file is searched in its own thread (using the multiprocessing module). If <strong>PROCESS_IN_PARALLEL</strong> is set to <em>False</em>, then each <em>.tgz</em> file is searched in sequence (using a loop).</p>
  
  <p><strong>What works:</strong>  </p>
  
  <ol>
  <li>I have a batch file on the VM that I use for testing my script. I can successfully use this <em>.bat</em> to call my script with <strong>PROCESS_IN_PARALLEL</strong> set to either (1a) <em>True</em> or (1b) <em>False</em>. Of course, it runs much faster when <em>True</em> (about 4x faster).<br>
  I have quadruple-checked that this <em>.bat</em> passes the same parameters to my script as Hudson, and in the same order. I have also added a line to my script that logs the input parameters to a file, and have found that Hudson is indeed passing the correct parameters in the correct order.  </li>
  <li>I can successfully use Hudson to call my script with <strong>PROCESS_IN_PARALLEL</strong> set to <em>False</em>.  </li>
  <li>I have tested the current iteration of my script using the above three test cases multiple times (even using multiple configurations of other parameters), all successfully.</li>
  </ol>
  
  <p><strong>What doesn't work:</strong><br>
  If I use Hudson to call my script with <strong>PROCESS_IN_PARALLEL</strong> set to <em>True</em>, then I get a strange error. Here is the traceback:  </p>
  
  <pre><code>Traceback (most recent call last):
    File "F:\Scripts\Parse_LogFiles_Archive\parseLogs_Archive_8-19-13.py", line 40, in main  
      searchHits = searchTarList(searchDir, newDirectory, argv)
    File "F:\Scripts\Parse_LogFiles_Archive\parseLogs_Archive_8-19-13.py", line 163, in searchTarList  
      hits = processPool.map(searchTar, tarMap)
    File "E:\Python27\lib\multiprocessing\pool.py", line 225, in map  
      return self.map_async(func, iterable, chunksize).get()
    File "E:\Python27\lib\multiprocessing\pool.py", line 522, in get  
      raise self._value   IOError: [Errno 9] Bad file descriptor 
  </code></pre>
  
  <p>According to my research, this error happens when Python attempts to read a file which is opened in write mode.</p>
  
  <p><strong>My question:</strong><br>
  Is there a genius out there who know both Python and Hudson well enough to know what is happening?</p>