HTTPClient::Timeout
httpclientä»å±ã®ãHTTPClient::Timeoutãã使ãã¨ãå¦çãæå®ãããæéã§å®äºããããã§ãã¯ãã¦ãå®äºããªãå ´åã¨ã©ã¼ã¨ããæ©è½ãç°¡åã«å®ç¾ã§ãã¾ãã
- åæ§ã®æ©è½ãæä¾ããæ¨æºæ·»ä»ã®ã©ã¤ãã©ãªã¨ãã¦timeout.rbãããã¾ãããããã¨æ¯è¼ãã¦ä»¥ä¸ã®ç¹ãæ¹åããã¦ããã¨ã®ãã¨ã
- timeout()ãå¼ã°ãããã¨ã«ã¹ã¬ãããçæããªãã1ã¹ã¬ããã§ãã¹ã¦ã®ãã§ãã¯ãè¡ãã
- timeoutãã§ãã¯ç¨ã¹ã¬ãã?ã®èµ·ååæ°ãå°ãªãã
- å¥ã®ã¹ã¬ãããèµ·åãã¦ãã§ãã¯ããç¹ã¯åããªã®ã§ã
- ãC è¨èªã¬ãã«ã§å®è£ ãããRuby ã®ã¹ã¬ãããå²ãè¾¼ããªãå¦çã«ã¯ç¡åããªã®ã¯åã(ã®ã¯ã)ã
- ã¾ããThread#criticalãè¨å®ãã¦ã¹ã¬ããåãæ¿ããæå¶ããç¶æ ã§ãå©ç¨ã§ãã¾ããã(ThreadErrorã«ãªãã¾ãã)
- ãªããå¼·å¶ãã£ã³ã»ã«ã®ä»çµã¿ã¯ãThread#raiseを使って例外を発生させるãæ¹å¼ã§ããããtimeout.rbã¨åãã§ãã
å©ç¨ä¾ã¯ä»¥ä¸ã
require 'rubygems' require 'httpclient' # 2ç§ã§å¦çãçµãããªããã°ã¨ã©ã¼ã«ãã include HTTPClient::Timeout timeout( 2 ) { sleep 5 }
å®è¡çµæã§ãã
/usr/lib/ruby/1.8/timeout.rb:60: execution expired (Timeout::Error) from xxx/httpclient_timeout.rb:6