Closing pexpect connections using threads

2007-10-03 Thread Vishal Sethia
I am trying to write a multi-threaded program and use pexpect along
with it. All works fine until I try to close the connection handle.
That thread keeps waiting until the connection handle closes. It
actually never comes out of that command(connection_handle.close()).
If I manually kill it using kill command, the thread comes out and
quits otherwise it is in the wait state forever.

  def daemon(self):
  self.continue_hearbeats_lock.acquire()
  self.continue_heartbeats = True
  self.continue_hearbeats_lock.release()
  thrdHandshake = threading.Event()
 threading.Thread(target=self.RunTests,name='Run_Te  st_Thread')

 while self.continue_heartbeats:
  pass
  def RunTests(self):
   self.createconnection()
   self.closeconnection()

  def closeconnection()
 self.log("Closing connection for device")
 self.connection_handle.close()


createconnection is a API which creates SSH connection to a remote machine.

And upon running, it hangs at this point
11:8:17:910 [DBG][CLEANUP]
11:8:17:910 [DBG]Closing Connection for device



Any tips on what I am missing here?

Thanks,

-V
-- 
http://mail.python.org/mailman/listinfo/python-list


Owner of spawned process in threads

2007-10-04 Thread Vishal Sethia
Just trying to understand the behaviour of spawn. Consider I have a
function which creates two threads. And in one of the threads I make a
call to pexpect.spawn. spawn would fork and create a new new child In
this case who becomes the owner of this child process.

Is it the thread that spawned becomes the owner or is the main program
becomes the owner of that child process.

Thanks,
-V
-- 
http://mail.python.org/mailman/listinfo/python-list