Article View: pl.comp.lang.ruby
Article #451Re: Timeout
From: Medyk
Date: Thu, 22 Feb 2007 16:14
Date: Thu, 22 Feb 2007 16:14
31 lines
1877 bytes
1877 bytes
Marcin Mielżyński wrote:
> Eh, zmyliłeś mnie tym timeout - to wogóle nie do tego służy
>
>
> require 'net/http'
>
> h = Net::HTTP.new("www.onet.pl")
> h.read_timeout = 600
> puts h.get('/').body
>
Dzięki! wygląda na to, że działa :)
Nie mniej nie bardzo rozumiem Twoje tłumaczenie, do czego jeśli nie do
tego w takim razie służy ten blok:
Timeout::timeout(s) { }
Dokumentacja mówi:
Executes the method‘s block. If the block execution terminates before
sec seconds has passed, it returns true. If not, it terminates the
execution and raises exception (which defaults to Timeout::Error).
Co jak rozumiem powinno dawać to czego oczekiwałem, pozwolenie na
wykonywanie się wewnętrznego kodu do czasu s.
Rozumiem, że błąd u mnie polegał na tym, że wsadzenie kodu w blok
Timeout nie miało wpływu na wewnętrzny timeout obiektu Net::HTTP, który
jedynie mogłem ustawić poprzez właściwość read_timeout. Dobrze rozumuję?
--
Medyk
http://www.medikoo.com/
Technical Details
Message-ID:
<erkfhe$bo8$1@inews.gazeta.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mailReferences:
<erial5$367$1@inews.gazeta.pl> <eric5b$d99$1@news.onet.pl> <erig83$q48$1@inews.gazeta.pl> <erih2e$ut2$1@news.onet.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail From: Medyk <usenet@medikoo.com> Newsgroups: pl.comp.lang.ruby Subject: Re: Timeout Date: Thu, 22 Feb 2007 17:14:37 +0100 Organization: "Portal Gazeta.pl -> http://www.gazeta.pl" Lines: 31 Message-ID: <erkfhe$bo8$1@inews.gazeta.pl> References: <erial5$367$1@inews.gazeta.pl> <eric5b$d99$1@news.onet.pl> <erig83$q48$1@inews.gazeta.pl> <erih2e$ut2$1@news.onet.pl> NNTP-Posting-Host: 81-dzi-1.acn.waw.pl Mime-Version: 1.0 X-Trace: inews.gazeta.pl 1172160878 12040 62.121.64.81 (22 Feb 2007 16:14:38 GMT) X-Complaints-To: usenet@agora.pl NNTP-Posting-Date: Thu, 22 Feb 2007 16:14:38 +0000 (UTC) X-User: mariuszn3 In-Reply-To: <erih2e$ut2$1@news.onet.pl> User-Agent: Thunderbird 2.0b2 (Windows/20070116) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit