title: Paramiko hangs forever when trying to wait until the command execution is finished on the remote server
body: <p>I want to export a database on the remove server and then download it either from local or another server.</p>
  <p>This is the command I'm trying to execute on the remote server: <code>mysqldump -u username -ppassword database_name | gzip test.sql.gz</code></p>
  <p>This is the code:</p>
  <pre><code>def ssh_with_private_key(host, port, username, key_path, command):
      key = paramiko.RSAKey.from_private_key_file(key_path)
      client = paramiko.SSHClient()
      policy = paramiko.AutoAddPolicy()
      client.set_missing_host_key_policy(policy)
      client.connect(host, port, username, pkey=key)
      stdin, stdout, stderr = client.exec_command(command)
  
      stdout.readlines()
  
      client.close()
  </code></pre>
  <p>When I call the <code>.readlines()</code> method, it starts to hang forever.</p>
  <p>I tried adding this line of code:</p>
  <pre><code>exit_status = _stdout.channel.recv_exit_status()
  print(exit_status)
  </code></pre>
  <p>But still the same result. It hangs forever</p>
  <p>Any kind of help would be appreciated</p>