Windows-在单独的过程中执行Ruby函数
我正在尝试在Windows系统上的单独过程中执行Ruby函数。在Mac上,我使用了fork
方法。但这在Windows上不起作用。我还尝试了Spawn
方法。但这似乎也不起作用。
def test_1
puts "Hello"
end
def test_2
puts " World"
end
在Windows上的Mac(Works)上
pid_1 = Fork.do
test_1
end
pid_2 = Fork.do
test_2
end
Process.waitall
(不起作用)
pid_1 = Process.spawn(test_1)
pid_2 = Process.spawn(test_2)
Process.waitall
Exception: NoMethodError - undefined method `spawn' for Process:Module
Ruby版本:2.0 有人可以帮助我理解我缺少的东西。
编辑:找到问题。 Ruby版本是旧版本(1.8.7),该版本未实现此方法。
I'm trying to execute Ruby functions in separate processes on my Windows system. On Mac, I used the Fork
method. But that doesn't work on Windows. I also tried the spawn
method. But that doesn't seem to work either.
def test_1
puts "Hello"
end
def test_2
puts " World"
end
On Mac (Works)
pid_1 = Fork.do
test_1
end
pid_2 = Fork.do
test_2
end
Process.waitall
On Windows (Doesn't work)
pid_1 = Process.spawn(test_1)
pid_2 = Process.spawn(test_2)
Process.waitall
Exception: NoMethodError - undefined method `spawn' for Process:Module
Ruby version: 2.0
Can someone help me in understanding what I'm missing.
Edit: Found the issue. The Ruby version was old (1.8.7) which doesn't implement this method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论