什么可能导致ruby在退出时锁定?

什么可能导致ruby在退出时锁定?,ruby,locking,exit,Ruby,Locking,Exit,我有一个ruby脚本,它执行一些perforce操作(通过脚本API),然后简单地结束: def foo() ... end def bar() ... end foo() bar() puts __LINE__ exit 0 #end of file …虽然将打印出行,但无论出口(0)是否存在,该过程永远不会结束。这是ruby 1.8.6,主要在mac上,但我在PC上也看到了这一点 我正在用谷歌搜索,但希望这里能有经验的声音。谢谢。我对perforce一点也不熟悉,但罪魁祸首可能

我有一个ruby脚本,它执行一些perforce操作(通过脚本API),然后简单地结束:

def foo()
  ...
end

def bar()
  ...
end

foo()
bar()
puts __LINE__
exit 0
#end of file
…虽然将打印出行,但无论出口(0)是否存在,该过程永远不会结束。这是ruby 1.8.6,主要在mac上,但我在PC上也看到了这一点


我正在用谷歌搜索,但希望这里能有经验的声音。谢谢。

我对perforce一点也不熟悉,但罪魁祸首可能是由于某种原因陷入循环的方法。使用
irb
观察行为,例如:

$ irb
irb(main):001:0> require 'time'
=> true
irb(main):002:0> at_exit { puts Time.now; sleep 10; puts Time.now }
=> #<Proc:0xb7656f64@(irb):2>
irb(main):003:0> exit
Fri Mar 12 19:46:25 -0500 2010
Fri Mar 12 19:46:35 -0500 2010
哪些产出:

at_exit 0 called at_exit 1 called Cleaning... at_exit 2 called Calling at_exit #2 from exitcheck.rb:14:in `do_cleanup'exitcheck.rb:18 Cleaning up before exit... Calling at_exit #1 from exitcheck.rb:10 I am about to leave. Calling at_exit #0 from exitcheck.rb:9 I'll never return 在_出口0呼叫 在1号出口呼叫 打扫。。。 在2号出口呼叫 在出口2号出口呼叫。rb:14:in'do#U cleanup'出口。rb:18 在出口前清理。。。 在出口1号出口呼叫。rb:10 我就要走了。 在出口处0号出口呼叫。rb:9 我再也不会回来了 永远不会回来

at_exit 0 called at_exit 1 called Cleaning... at_exit 2 called Calling at_exit #2 from exitcheck.rb:14:in `do_cleanup'exitcheck.rb:18 Cleaning up before exit... Calling at_exit #1 from exitcheck.rb:10 I am about to leave. Calling at_exit #0 from exitcheck.rb:9 I'll never return