<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>tmtms</author_name>
  <author_url>https://blog.hatena.ne.jp/tmtms/</author_url>
  <blog_title>tmtms のメモ</blog_title>
  <blog_url>https://blog.tmtms.net/</blog_url>
  <categories>
    <anon>Ruby</anon>
  </categories>
  <description>ちょっとハマったのでメモ。 Ruby の Timeout ライブラリを使うと、一定の時間が過ぎても終わらない処理を中断することができます。 require 'timeout' def hoge sleep end def main Timeout.timeout(3) do hoge end rescue Timeout::Error =&gt; e p 'main: timeout', e.backtrace.first end main このスクリプトを実行すると3秒たってから終了します。 % ruby t1.rb &quot;main: timeout&quot; &quot;t1.rb:4:in `sleep'&quot; バック…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fblog.tmtms.net%2Fentry%2F2014%2F06%2F19%2Fruby-timeout&quot; title=&quot;Ruby の Timeout.timeout に例外クラスを指定する時の注意 - tmtms のメモ&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2014-06-19 06:48:12</published>
  <title>Ruby の Timeout.timeout に例外クラスを指定する時の注意</title>
  <type>rich</type>
  <url>https://blog.tmtms.net/entry/2014/06/19/ruby-timeout</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
