From: Bryan B. <br...@bu...> - 2007-07-16 11:40:11
|
> Hmm, could be the wait delay in soft/hard_close which is trying to > send signals to the spawned process via "kill". Maybe that also > doesn't work in a thread (like fork()). Could you try closing the > Expect objects in the main thread? Maybe that gets rid of the delay... > > Seems a sensible rule to me: "Create and destroy Expect objects only > in the main thread." > Actually its the other way around. If i soft/hard close the object in the thread it takes a reasonable amount of time. If I soft/hard close it in the main thread it takes longer. The actual delay is in the join function, then closing the objects works normally. I re-wrote the last script to output the number of seconds elapsed and here is the output: Getting expect object for mythtv: 0 seconds Getting expect object for valhalla: 0 seconds Getting expect object for eldorado: 0 seconds Spawning thread: 1 seconds Spawning thread: 1 seconds Spawning thread: 1 seconds Joining thread 0 (mythtv): 1 seconds Completed joining thread 0 (mythtv): 16 seconds Closing expect object: 16 seconds Joining thread 1 (eldorado): 16 seconds Completed joining thread 1 (eldorado): 16 seconds Closing expect object: 16 seconds Joining thread 2 (valhalla): 16 seconds Completed joining thread 2 (valhalla): 16 seconds Closing expect object: 16 seconds You can see it takes about 15 seconds to join the first thread and then things progress normally. > > BTW, anybody tried to use Net::SSH2 instead of spawning ssh? Net::SSH2 > objects are tied filehandles, so they should be usable via > exp_init()... > > Cheers! > Roland > I persued Net::SSH2 over a year ago for just this purpose. You can read the thread I had with the author here: http://sourceforge.net/mailarchive/message.php?msg_id=200601192208.43932.dbrobins%40cpan.org Basically David Robins stated this: Ah, then there's the problem. Fileno tries to get a real Unix filehandle out of the object; since it isn't a real Unix file, you won't get one. I could not get it to work, and David seemed to think that it should not work. In that thread there is very simple code that I wrote and even that doesnt work. However, all that aside, even without using Expect, Net::SSH2 was not thread safe. I sent emails regarding that as well, to no avail. At this point in time, I really think Expect on top of a spawned ssh command is the best way to do things (from a perl perspective). Thanks Bryan Bueter http://sourceforge.net/projects/rover |