zscheduler 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zscheduler.rb +15 -1
- data/lib/zscheduler/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b32443bc9d6b88da1b988443981dd24b4e4c2d0
|
4
|
+
data.tar.gz: 2861072369ad25e8f1ced0b904e91105066d4ded
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 815510c3ee6f65a0b279e8994c26098f6a18943ff749db1b4156a13ff195caa15efee87b13da6d9d832574b1c01d644320074d9455d2b9a0aa316d049bb3b9d1
|
7
|
+
data.tar.gz: 99743ee62d00a2433ea5528affb281c74996d5a407705a1d78c869f6a269f4c5495b3f544271824f1b481845c735c04616a2dba1d5bdcb09ba726ffa3cb1fe08
|
data/lib/zscheduler.rb
CHANGED
@@ -51,6 +51,7 @@ module Zscheduler
|
|
51
51
|
#
|
52
52
|
def every(frequency,options = {}, &block)
|
53
53
|
block_given? or raise ArgumentError, "no block was given..."
|
54
|
+
block = wrap block
|
54
55
|
start_reactor
|
55
56
|
|
56
57
|
add_shutdown_hook(&block) if options[:on_shutdown]
|
@@ -89,7 +90,7 @@ module Zscheduler
|
|
89
90
|
def once(seconds, &block)
|
90
91
|
start_reactor
|
91
92
|
seconds = (seconds - Time.now) if seconds.kind_of?(Time)
|
92
|
-
timers.push(Timer.new(EM::Timer.new(seconds.to_i,&block))).last
|
93
|
+
timers.push(Timer.new(EM::Timer.new(seconds.to_i,&wrap(block)))).last
|
93
94
|
end
|
94
95
|
|
95
96
|
# Stop the scheduler, cancel all timers and run all the shutdown hooks
|
@@ -122,6 +123,19 @@ module Zscheduler
|
|
122
123
|
|
123
124
|
private
|
124
125
|
|
126
|
+
def wrap block
|
127
|
+
proc do
|
128
|
+
begin
|
129
|
+
block.call
|
130
|
+
rescue Exception => e
|
131
|
+
init_reactor? ?
|
132
|
+
raise :
|
133
|
+
STDERR.puts("[ZScheduler][#{block.source_location.join(":")}]" +
|
134
|
+
"#{e.message}\n#{e.backtrace.join("\n")}")
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
125
139
|
def start_reactor
|
126
140
|
return if EM.reactor_running?
|
127
141
|
@wrapper = Thread.new(&EM.method(:run))
|
data/lib/zscheduler/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zscheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eran Barak Levi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|