我有一个调用在线程内部运行的方法的服务。但是线程中的代码可以访问其他模块方法。当调用module方法时,线程会受到攻击。
服务:
def place_order
threads = []
@responses = []
order_params.each_with_index do |order, index|
threads << Thread.new do
@responses << Module1::Class1.place_order(order)
end
end
threads.each &:join
@responses
end模块1::class1的place_order方法:
def place_order(options)
order_params = { body: order_config(options).to_json }
resp = make_request(:post, "/v3/order/", order_params).parsed_response
Rails.logger.info "QWIK_CILVER::ORDERResponse:: #{resp.inspect}"
***The below code calls a method in different module which is not running******
Module2::SubModule1::Class1.parse(resp, self)
endTHe服务器挂起了,在那之后我甚至无法停止服务器。必须手动终止进程,然后重新启动服务器。如何在线程中调用Module2::SubModule1::class1的方法?
PS:如果我从控制台调用相同的服务,一切都会正常工作。但是如果我从postman调用,服务器会在模块方法调用点挂起。
发布于 2019-12-05 18:23:55
已跟踪问题。运行应用程序生产模式,相同的代码运行良好。在开发模式下,这是一个简单的类加载问题。
https://stackoverflow.com/questions/59176908
复制相似问题