Ruby Timeout::timeout doesn't fire Exception and doesn't return what documented

后端 未结 3 2187
野的像风
野的像风 2021-02-14 09:39

I have this piece of code:

begin
  complete_results = Timeout.timeout(4) do      
    results = platform.search(artist, album_name)
  end
rescue Timeout::Error
           


        
3条回答
  •  你的背包
    2021-02-14 10:16

    Your code is correct

    require 'timeout'
    begin
      complete_results = Timeout.timeout(1) do      
       sleep(2)
      end
    rescue Timeout::Error
      puts 'Print me something please'
    end
    

    does print out "print me something please".

    Try the basic code as above. If that works, you have an issue in platform.search.

提交回复
热议问题