On Aug 12, 2008, at 12:38 PM, Bryan Richardson wrote: > def timeout(sec, pid) > begin > watchdog = IO.popen "ruby -e 'sleep(#{sec}); > Process.kill(:KILL.to_s, #{pid}) rescue nil'" > yield > ensure > Process.kill('KILL', watchdog.pid) rescue nil > end > end > > and I could call it like this: > > @sim = WIN32OLE.new 'PwrWorld.SimulatorAuto' > ... > begin > timeout(20, @sim.ProcessID) do > @sim.RunScriptCommand('SolvePrimalLP()') > end > rescue WIN32OLERuntimeError > # rescue myself from the external application hanging up... i.e. > reinitialize @sim > end > > However, it seems as though when creating the watchdog in the timeout > method IO.popen sometimes blocks execution. I can't tell if it's due > to the external (OLE) application blocking or something else. If I > don't use the timeout method the OLE application blocks at a different > time in the simulation, so I'm thinking it's not due to the OLE > application blocking... can you prove that it's popen blocking? seems very strange... a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama