From f845d5f1f6ee8e0c6b5f257af20603de52a55387 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Tue, 25 Jul 2023 19:35:18 -0400 Subject: [PATCH] Fix: intervals may not always be started in an async block. --- CHANGELOG.md | 1 + lib/slack-ruby-bot-server/service.rb | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2915e1c..502443a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### 2.1.1 (Next) +* [#172](https://github.com/slack-ruby/slack-ruby-bot-server/pull/172): Fix: intervals may not always be started in an async block - [@dblock](https://github.com/dblock). * Your contribution here. ### 2.1.0 (2023/03/06) diff --git a/lib/slack-ruby-bot-server/service.rb b/lib/slack-ruby-bot-server/service.rb index a8d8461..c500264 100644 --- a/lib/slack-ruby-bot-server/service.rb +++ b/lib/slack-ruby-bot-server/service.rb @@ -79,11 +79,13 @@ def start_from_database! end def start_intervals! - @intervals.each_pair do |period, calls_with_options| - calls_with_options.each do |call_with_options| - call, options = *call_with_options - _every period, options do - call.call + ::Async::Reactor.run do + @intervals.each_pair do |period, calls_with_options| + calls_with_options.each do |call_with_options| + call, options = *call_with_options + _every period, options do + call.call + end end end end