为什么当我在线程中时无法访问某些库类?
为什么下面会
require "bio"
threads = (1..2).map do
Thread.new do
seqs = ["gattaca"] * 5
alignment = Bio::Alignment.new(seqs)
end
end
threads.each {|th| th.join} ; nil
给出这个错误信息?
NameError: uninitialized constant Bio::Alignment
from (irb):6
from (irb):10:in `join'
from (irb):10
from (irb):10:in `each'
from (irb):10
Why does the following
require "bio"
threads = (1..2).map do
Thread.new do
seqs = ["gattaca"] * 5
alignment = Bio::Alignment.new(seqs)
end
end
threads.each {|th| th.join} ; nil
give this error message?
NameError: uninitialized constant Bio::Alignment
from (irb):6
from (irb):10:in `join'
from (irb):10
from (irb):10:in `each'
from (irb):10
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
bioruby 库(或至少它的某些版本)使用自动加载。自动加载不是线程安全的(至少在 ruby 1.8 中),因此如果两个线程同时访问 Bio::Alignment,则可能会出现错误。
The bioruby library (or at least some versions of it) use autoload. Autoload isn't thread-safe (at least in ruby 1.8), so if two threads are accessing Bio::Alignment at the same time, you can have errors.