timeout 0.3.2 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.document +3 -0
- data/{LICENSE.txt → BSDL} +3 -3
- data/COPYING +56 -0
- data/Gemfile +1 -0
- data/README.md +1 -5
- data/lib/timeout.rb +18 -25
- data/timeout.gemspec +4 -1
- metadata +11 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9390c49817b43adbd0f8eabd5d93f5535fd01a2d8007c901cdb0a4a85c8702eb
|
4
|
+
data.tar.gz: a8a0e97bf6a3f61eb0911911b476396b265ee0088aaeecfb136efcfb68799bbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0c3e963a4bb920583921a854057fc4c1b0f89d9c7a5a44a27e59455ce74c81e98486f9fe2904124bd25a601ed420f5ec47374ed48480ab97d65f3f837b0549a
|
7
|
+
data.tar.gz: 23e8bb2e41674a81dcf8440184e66565afdd69b08f0d4402cbc0a27453d2afab9d10bad8905f92aac2be22a41dc20cdcfc70f7f6d87ca6019e8815de57362492
|
data/.document
ADDED
data/{LICENSE.txt → BSDL}
RENAMED
@@ -4,10 +4,10 @@ Redistribution and use in source and binary forms, with or without
|
|
4
4
|
modification, are permitted provided that the following conditions
|
5
5
|
are met:
|
6
6
|
1. Redistributions of source code must retain the above copyright
|
7
|
-
notice, this list of conditions and the following disclaimer.
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
8
|
2. Redistributions in binary form must reproduce the above copyright
|
9
|
-
notice, this list of conditions and the following disclaimer in the
|
10
|
-
documentation and/or other materials provided with the distribution.
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
11
|
|
12
12
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
13
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
data/COPYING
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the
|
3
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a. place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b. use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c. give non-standard binaries non-standard names, with
|
21
|
+
instructions on where to get the original software distribution.
|
22
|
+
|
23
|
+
d. make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or binary form,
|
26
|
+
provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a. distribute the binaries and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b. accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c. give non-standard binaries non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d. make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under these terms.
|
43
|
+
|
44
|
+
For the list of those files and their copying conditions, see the
|
45
|
+
file LEGAL.
|
46
|
+
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
48
|
+
output from the software do not automatically fall under the
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
51
|
+
software.
|
52
|
+
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
56
|
+
PURPOSE.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,10 +3,6 @@
|
|
3
3
|
Timeout provides a way to auto-terminate a potentially long-running
|
4
4
|
operation if it hasn't finished in a fixed amount of time.
|
5
5
|
|
6
|
-
Previous versions didn't use a module for namespacing, however
|
7
|
-
#timeout is provided for backwards compatibility. You
|
8
|
-
should prefer Timeout.timeout instead.
|
9
|
-
|
10
6
|
## Installation
|
11
7
|
|
12
8
|
Add this line to your application's Gemfile:
|
@@ -27,7 +23,7 @@ Or install it yourself as:
|
|
27
23
|
|
28
24
|
```ruby
|
29
25
|
require 'timeout'
|
30
|
-
status = Timeout
|
26
|
+
status = Timeout.timeout(5) {
|
31
27
|
# Something that should be interrupted if it takes more than 5 seconds...
|
32
28
|
}
|
33
29
|
```
|
data/lib/timeout.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# == Synopsis
|
5
5
|
#
|
6
6
|
# require 'timeout'
|
7
|
-
# status = Timeout
|
7
|
+
# status = Timeout.timeout(5) {
|
8
8
|
# # Something that should be interrupted if it takes more than 5 seconds...
|
9
9
|
# }
|
10
10
|
#
|
@@ -13,39 +13,33 @@
|
|
13
13
|
# Timeout provides a way to auto-terminate a potentially long-running
|
14
14
|
# operation if it hasn't finished in a fixed amount of time.
|
15
15
|
#
|
16
|
-
# Previous versions didn't use a module for namespacing, however
|
17
|
-
# #timeout is provided for backwards compatibility. You
|
18
|
-
# should prefer Timeout.timeout instead.
|
19
|
-
#
|
20
16
|
# == Copyright
|
21
17
|
#
|
22
18
|
# Copyright:: (C) 2000 Network Applied Communication Laboratory, Inc.
|
23
19
|
# Copyright:: (C) 2000 Information-technology Promotion Agency, Japan
|
24
20
|
|
25
21
|
module Timeout
|
26
|
-
|
22
|
+
# The version
|
23
|
+
VERSION = "0.4.2"
|
24
|
+
|
25
|
+
# Internal error raised to when a timeout is triggered.
|
26
|
+
class ExitException < Exception
|
27
|
+
def exception(*) # :nodoc:
|
28
|
+
self
|
29
|
+
end
|
30
|
+
end
|
27
31
|
|
28
32
|
# Raised by Timeout.timeout when the block times out.
|
29
33
|
class Error < RuntimeError
|
30
|
-
|
34
|
+
def self.handle_timeout(message) # :nodoc:
|
35
|
+
exc = ExitException.new(message)
|
31
36
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
|
39
|
-
def exception(*)
|
40
|
-
# TODO: use Fiber.current to see if self can be thrown
|
41
|
-
if self.thread == Thread.current
|
42
|
-
bt = caller
|
43
|
-
begin
|
44
|
-
throw(@catch_value, bt)
|
45
|
-
rescue UncaughtThrowError
|
46
|
-
end
|
37
|
+
begin
|
38
|
+
yield exc
|
39
|
+
rescue ExitException => e
|
40
|
+
raise new(message) if exc.equal?(e)
|
41
|
+
raise
|
47
42
|
end
|
48
|
-
super
|
49
43
|
end
|
50
44
|
end
|
51
45
|
|
@@ -195,8 +189,7 @@ module Timeout
|
|
195
189
|
if klass
|
196
190
|
perform.call(klass)
|
197
191
|
else
|
198
|
-
|
199
|
-
raise Error, message, backtrace
|
192
|
+
Error.handle_timeout(message, &perform)
|
200
193
|
end
|
201
194
|
end
|
202
195
|
module_function :timeout
|
data/timeout.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
name = File.basename(__FILE__, ".gemspec")
|
4
|
-
version = ["lib", Array.new(name.count("-")+1, "
|
4
|
+
version = ["lib", Array.new(name.count("-")+1, ".").join("/")].find do |dir|
|
5
5
|
break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
|
6
6
|
/^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
|
7
7
|
end rescue nil
|
@@ -20,6 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.metadata["homepage_uri"] = spec.homepage
|
22
22
|
spec.metadata["source_code_uri"] = spec.homepage
|
23
|
+
spec.metadata["changelog_uri"] = spec.homepage + "/releases"
|
24
|
+
|
25
|
+
spec.required_ruby_version = '>= 2.6.0'
|
23
26
|
|
24
27
|
spec.files = Dir.chdir(__dir__) do
|
25
28
|
`git ls-files -z`.split("\x0").reject do |f|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timeout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yukihiro Matsumoto
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Auto-terminate potentially long-running operations in Ruby.
|
14
14
|
email:
|
@@ -17,8 +17,10 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".document"
|
21
|
+
- BSDL
|
22
|
+
- COPYING
|
20
23
|
- Gemfile
|
21
|
-
- LICENSE.txt
|
22
24
|
- README.md
|
23
25
|
- lib/timeout.rb
|
24
26
|
- timeout.gemspec
|
@@ -29,7 +31,8 @@ licenses:
|
|
29
31
|
metadata:
|
30
32
|
homepage_uri: https://github.com/ruby/timeout
|
31
33
|
source_code_uri: https://github.com/ruby/timeout
|
32
|
-
|
34
|
+
changelog_uri: https://github.com/ruby/timeout/releases
|
35
|
+
post_install_message:
|
33
36
|
rdoc_options: []
|
34
37
|
require_paths:
|
35
38
|
- lib
|
@@ -37,15 +40,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
37
40
|
requirements:
|
38
41
|
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
43
|
+
version: 2.6.0
|
41
44
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
45
|
requirements:
|
43
46
|
- - ">="
|
44
47
|
- !ruby/object:Gem::Version
|
45
48
|
version: '0'
|
46
49
|
requirements: []
|
47
|
-
rubygems_version: 3.5.
|
48
|
-
signing_key:
|
50
|
+
rubygems_version: 3.5.11
|
51
|
+
signing_key:
|
49
52
|
specification_version: 4
|
50
53
|
summary: Auto-terminate potentially long-running operations in Ruby.
|
51
54
|
test_files: []
|