Closing pexpect connections using threads

V

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
<pexpect.spawn instance at 0xb7b373cc>


Any tips on what I am missing here?

Thanks,

-V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top