Ruby ã§é·ãæéæããããç¥ããªãå¦çã®ã¿ã¤ã ã¢ã¦ããè¡ãã«ã¯ãããªæãã«ãã¾ãã require 'timeout' begin Timeout.timeout(3) do # 3ç§ã§ã¿ã¤ã ã¢ã¦ã hoge # ä½ãã®å¦ç end rescue Timeout::Error puts 'ãªãã¼ã' # ã¿ã¤ã ã¢ã¦ãçºçæã®å¦ç end Timeout.timeout ã¯ãããã¯éå§æã«ã¹ã¬ãããä½æãããã®ã¹ã¬ããã§æå®ãããç§æ°ã ã sleep ãã¦ãsleep ãã復帰ãã¦ãã¾ã ãããã¯ãçµãã£ã¦ãªããã°ä½æå ã®ã¹ã¬ããã«å¯¾ã㦠Timeout::Error ä¾å¤ãçºçããã¾ãã æå®æé以å ã«å¦çãçµããå ´å: timeout(X) â ã¹ã¬ããä½æ ââ â â ãããã¯å®è¡ sleep X â â ã¹ã¬ããkillâ ð± â timeout復帰 æå®æé以å ã«å¦çãçµãã
{{#tags}}- {{label}}
{{/tags}}