title: Python Multiprocessing, TypeError
body: <p>I am new to multiprocessing and I need your help.</p>
  <p>I have four variables that each of them can take up to 4 values (integers or floats) and I stored all of them in a list called <code>par=[A, B, C, D]</code>. (see below)</p>
  <p>I have created a list of possible combinations with <code>par = itertools.product(*par)</code> .</p>
  <p>Then, I call a function <code>func1</code>, that takes these arguments and some more and calculates stuff. With the results of the <code>func1</code>, I call another function that calculates stuff and then writes to a file.</p>
  <p>I want to run these as a whole in parallel with <code>multiprocessing.Pool</code> I thought to embed <code>func1</code> and <code>func2</code> in another function, called <code>func_run</code>, and map this with the list <code>par</code> I created above.</p>
  <p>To summarize, my code looks like:</p>
  <pre><code>#values that I will use for func1
      
  r   = np.logspace(np.log10(5),np.log10(300),300)
  T   = 200*r
  
  #Parameters for the sim
  A = [0.1, 0.05, 0.001, 0.005]
  B = [0.005, 0.025, 0.05, 0.1]
  C = [20, 60, 100, 200]
  D = [10, 20, 40, 80]
  
  #Store them in a list
  par = [A, B, C, D]
  
  #Create a list with all combinations
  par = list(itertools.product(*par))             
  
  def func_run(param):
      for i in range(len(param)):
  
  # Call func1
          values = func1(param[i][0],param[i][1],param[i][2], param[i][3], r, T)
  
          x = values[0]
          y = values[1]
          # and so on
          
  # Call func2
          results = func2(x,y,...)
  
          z = results[0]
          w = results[1]
          # and so on
  
          data_dict = {'result 1': [param[i][0]], 'result 2' : [param[i][1]]}
  
      df = pd.DataFrame(data=data_dict)
          with open(filename, 'a') as f:
                  df.to_csv(f, header=False)
        
      return
  </code></pre>
  <p>Then, I call the <code>func_run</code> with <code>multiprocessing</code>.</p>
  <pre><code>from multiprocessing import Pool
  pool = Pool(processes=4)
  results = pool.map(func_run, par)
  </code></pre>
  <p>As a result, I get a, <code>TypeError</code> with traceback:</p>
  <pre><code>---------------------------------------------------------------------------
  RemoteTraceback                           Traceback (most recent call last)
  RemoteTraceback: 
  &quot;&quot;&quot;
  Traceback (most recent call last):
    File &quot;/home/user/anaconda3/lib/python3.6/multiprocessing/pool.py&quot;, line 119, in worker
  result = (True, func(*args, **kwds))
    File &quot;/home/user/anaconda3/lib/python3.6/multiprocessing/pool.py&quot;, line 44, in mapstar
  return list(map(*args))
    File &quot;&lt;ipython-input-14-5ce94acfd95e&gt;&quot;, line 5, in run
  values = calc_val(param[i][0],param[i][1],param[i][2], param[i][3], r, T)
  TypeError: 'float' object is not subscriptable
  &quot;&quot;&quot;
  
  The above exception was the direct cause of the following exception:
  
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-15-f45146f68f66&gt; in &lt;module&gt;()
        1 pool    = Pool(processes=4)
  ----&gt; 2 test    = pool.map(run,par)
  
  ~/anaconda3/lib/python3.6/multiprocessing/pool.py in map(self, func, iterable, chunksize)
  264         in a list that is returned.
  265         '''
  --&gt; 266         return self._map_async(func, iterable, mapstar, chunksize).get()
  267 
  268     def starmap(self, func, iterable, chunksize=None):
  
  ~/anaconda3/lib/python3.6/multiprocessing/pool.py in get(self, timeout)
  642             return self._value
  643         else:
  --&gt; 644             raise self._value
  645 
  646     def _set(self, i, obj):
  
  TypeError: 'float' object is not subscriptable
  </code></pre>
  <p>Unfortunately, it is impossible to add the whole functions and what are they doing because they are hundreds of lines. I hope that you can get the feeling though even though you cannot really reproduce it by yourselfs.</p>
  <p>Is it possible to run something like this with multiprocessing or I need a different approach?
  It would be great if anyone can help me understand the error and make it run.</p>