0
다음 애플리케이션에서 연기를내는 12 개의 프로세스를 실행하는 루비 스크립트가 있습니다. 이 중 일부는 최대 8 분까지 장시간 실행될 수 있습니다.Ruby : Process.wait는 +300 초의 긴 연산에 대해 '잘못된 인수'예외를 던지고 있습니다.
pids = []
pids = uris.map do |uri|
print_start(uri)
command = get_http_tests_command("Smoke")
update_http_tests_config(uri)
pid = Process.spawn command
Process.detach pid
pid
end
print("smoke tests in progress => #{pids} => #{uris}")
statuses = pids.map do |pid|
puts "waiting for #{pid}"
Process.wait(pid)
$?
end
print("smoke tests finished")
과정에 관계없이 성공 끝나면 나는 간헐적으로 Process.wait(pid)
행에 오류가 발생합니다. 오류는 다음과 같습니다.
#<Errno::EINVAL: Invalid argument>
>> SmokeTest.rb:169:in "wait"
>> SmokeTest.rb:169:in "block in run_single"
>> SmokeTest.rb:167:in "map"
>> SmokeTest.rb:167:in "run_single"
나는 여기에 무슨 일이 일어나고 있는지 잘 모르겠지만 어떤 도움을 많이 주시면 감사하겠습니다. 300 초에서 3 회에 1 회 정도 간헐적으로 실패하는 것 같습니다. 300 초가 넘으면 항상 실패합니다.
약간 두껍습니다.이'threads.each (& : join) '의 목적은 무엇입니까? – Neil
각각의 제목은'&'입니까? 아마도 차단을위한 것일까요? – Neil
이것은 'threads.each {| x | 모든 스레드가 완료 될 때까지 대기하는 'x.join}' –