title: Can threads create sub-threads in Python?
body: <p>I am familiar with the syntax for creating threads in python.</p>
  
  <pre class="lang-python prettyprint-override"><code>from threading import Thread
  from queue import Queue
  
  task_queue = Queue(maxsize=0)    
  
  num_threads=10
  for i in range(num_threads):
      thread = Thread(target=work, args=(task_queue,))
      thread.start()
  
  task_queue.join()
  </code></pre>
  
  <p>My question is weather it is ok to open up new threads 'inside' other threads like so:</p>
  
  <pre class="lang-python prettyprint-override"><code>def work(task_queue):
      task = task_queue.get()
  
      subtasks = task.get_sub_tasks()
  
      for subtask in subtasks:
          thread = Thread(target=sub_work, args(subtask,))
          thread.start()
  </code></pre>
  
  <p>So</p>
  
  <ol>
  <li><p>Is this structure ok? or is it to messy to do it this way?</p></li>
  <li><p>If this is ok, are the sub-thread processes subordinated to the thread that generated it, or do they become children of the parent python process? If the thread that created the sub-thread "dies" with an error, what happens to the sub-thread?</p></li>
  </ol>
  
  <p>I realize python threads are subject to the interpreter global lock, but my application involves access to a server, so the multi threading is to avoid serialized connections which would take too long.</p>