ruby_timeout_safe 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -1
- data/lib/ruby_timeout_safe/version.rb +1 -1
- data/lib/ruby_timeout_safe.rb +2 -3
- metadata +3 -3
- /data/{.rubcop.yml → .rubocop.yml} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 851e38c367c7d9625dd267f049938fe5761b0580597ad73b18c069983a2d24aa
|
4
|
+
data.tar.gz: 768f4eb26f2eb1c5c7fe0e251999fe9e58b1f52239d5e12c16440ac6b48e25d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8ef40a988be4c1366a6fd344d34c7eaf1184cbb1d57d65549fc663c1731c9fee92714d8539d08e4b0f71cd391cfca1ae94d1d3816e31ec451a7604e48181bb0
|
7
|
+
data.tar.gz: 95e5857db3003d69bd876e1db2ef12f2b22171310f0c802ac634beb16bea37ea425ce48bc53366eed70cd4788dad8977f98b48a1b071f6f16849297becc698c2
|
data/.rspec
CHANGED
data/lib/ruby_timeout_safe.rb
CHANGED
@@ -5,10 +5,9 @@ require_relative 'ruby_timeout_safe/version'
|
|
5
5
|
|
6
6
|
# A safe timeout implementation for Ruby using monotonic time.
|
7
7
|
module RubyTimeoutSafe
|
8
|
-
def self.timeout(seconds=nil)
|
8
|
+
def self.timeout(seconds = nil)
|
9
9
|
return yield if seconds.nil? || seconds.zero?
|
10
10
|
|
11
|
-
raise ArgumentError, 'timeout value must be at least 0.1 second' if seconds < 0.1
|
12
11
|
current_thread = Thread.current
|
13
12
|
|
14
13
|
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
@@ -17,7 +16,7 @@ module RubyTimeoutSafe
|
|
17
16
|
elapsed_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start_time
|
18
17
|
break if elapsed_time >= seconds
|
19
18
|
|
20
|
-
|
19
|
+
Thread.pass
|
21
20
|
end
|
22
21
|
current_thread.raise Timeout::Error, 'execution expired'
|
23
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_timeout_safe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sebi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
ruby-timeout-safe is a Ruby library that provides a safe and reliable timeout
|
@@ -29,7 +29,7 @@ extensions: []
|
|
29
29
|
extra_rdoc_files: []
|
30
30
|
files:
|
31
31
|
- ".rspec"
|
32
|
-
- ".
|
32
|
+
- ".rubocop.yml"
|
33
33
|
- CODE_OF_CONDUCT.md
|
34
34
|
- LICENSE.txt
|
35
35
|
- README.md
|
File without changes
|