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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 562203898edca53d3c2f91753e1725c7697c9c05
4
- data.tar.gz: 8f0e2e187e27e842dac04dbc042c0d5a05120cfb
3
+ metadata.gz: 8b32443bc9d6b88da1b988443981dd24b4e4c2d0
4
+ data.tar.gz: 2861072369ad25e8f1ced0b904e91105066d4ded
5
5
  SHA512:
6
- metadata.gz: 14aef601a9f01879be5a3f04b38d15ad4fcc0a3e1268b4d17bc4e4a4f3cdaa20cdb07c1dfcaf4063ac14d398fabfab5e376a7332543e125833facce3715b9c45
7
- data.tar.gz: d92b50e4d96953b14ff28cb3953c5519e44daaa8b0f63c52a74ff16e0a4dadf0af7faf86a3b5c095e08d8d624f48c702ac19c76cf3058ad0923b45aed492ff76
6
+ metadata.gz: 815510c3ee6f65a0b279e8994c26098f6a18943ff749db1b4156a13ff195caa15efee87b13da6d9d832574b1c01d644320074d9455d2b9a0aa316d049bb3b9d1
7
+ data.tar.gz: 99743ee62d00a2433ea5528affb281c74996d5a407705a1d78c869f6a269f4c5495b3f544271824f1b481845c735c04616a2dba1d5bdcb09ba726ffa3cb1fe08
@@ -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))
@@ -1,3 +1,3 @@
1
1
  module Zscheduler
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
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.7
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-19 00:00:00.000000000 Z
11
+ date: 2017-12-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine