title: os.system and subprocess.run make my multi threaded process freeze until call ends
body: <p>I am new to python and having some problems.</p>
  <p>I wrote an update_manager class that can communicate with the user via Tcp and preform installations of different components.</p>
  <p>My update_manager class uses 2 other classes(they are his members) to accomplish this. The first is used for TCP communication and the second for actual installation. the installation class runs from the main thread and the communication is run by using Threading.thread() function.</p>
  <p>my <strong>main</strong> locks like this:</p>
  <pre><code>if __name__ == &quot;__main__&quot;:
      new_update = UpdateManager()
  
      #time.sleep(10)
      new_update.run()
  </code></pre>
  <p>and the run functions is:</p>
  <pre><code>def run(self):
  
      comm_thread = threading.Thread(target=  
                    self._comm_agent.start_server_tcp_comunication)
                    comm_thread.start()
  
      while True:
  
          if (False == self.is_recovery_required()):
  
              self.calculate_free_storage_for_update_zip_extraction()
              self.start_communication_with_client_in_state_machine()
  
          self._comm_agent.disable_synchronized_communication()
          self.start_update_install()
          self._comm_agent.enable_synchronized_communication()
  
          if (True == self.is_dry_run_requested()):
              self.preform_cleanup_after_dry_run()
              
          else:
              self.reset_valid_states()
              self.preform_clean_up_after_update_cycle()
  </code></pre>
  <p>I use 2 multiprocessing.Queue() to sync between the threads and between the user. One for incoming messages and one for outgoing messages.</p>
  <p>At first TCP communication is synchronous, user provides installation file and few other things.</p>
  <p>Once installation begins TCP communication is no longer synchronous.</p>
  <p>During the installation I use 4 different install methods. and all but one work just fine with no problem(user can pool the update_manager process and ask progress questions and get immediate a reply)</p>
  <p>The problematic one is the instantiation of rpm files. for this I tried calling for os.system() and subprocess.run() and it works but for big rpm files I notices the entire process with my threads freezes until
  the call finishes(I can see the progress bar of rpm installation on my screen during this freeze).</p>
  <p>What I noticed and tried:
  1.There is no freeze during other installation methods which use python.
  libraries.</p>
  <p>2.Once user connects via TCP there are only 2 threads for the update_manager, once first request is sent and a reply is send back 2 more threads appear (I assume it have something to do with the queues I use).</p>
  <p>3.I created third thread that prints time(and has nothing to do with the queues), and I start it as soon as update_manager process starts. When the 2 threads freeze this one keeps going.</p>
  <p>4.On some rare occasions process will unfreeze just for a message to go throw from client to update_manager and freeze back.</p>
  <p>Edit: I forgot one more important point
  5. The freeze occurs when calling:
  os.system(&quot;rpm --nodeps --force -ivh rpm_file_name&quot;)</p>
  <p>But does not happen when calling:
  os.system(&quot;sleep 5&quot;)</p>
  <p>I would really appreciate some indigent, Thanks.</p>