falcon icon indicating copy to clipboard operation
falcon copied to clipboard

How to start periodically task inside falcon?

Open sergio-fry opened this issue 3 years ago • 4 comments

I am going to build all-in-one application: web, RMQ consumer, periodically tasks, etc. I can't understand how to do it with falcon. I can't access Asyc::Task.current directly, because it is not initialized inside config.ru. Could you explain how can I do that?

sergio-fry avatar Dec 09 '21 08:12 sergio-fry

@sergio-fry I guess this is no longer relevant but let me just leave it here.

https://github.com/socketry/timers

require 'timers'

timers = Timers::Group.new

five_second_timer = timers.after(5) { puts "Take five" }
every_five_seconds = timers.every(5) { puts "Another 5 seconds" }

loop { timers.wait }

webgago avatar Oct 09 '22 18:10 webgago

We can probably change this so that the config.ru is constructed within the top level async block... let me check.

ioquatix avatar Oct 10 '22 02:10 ioquatix

@webgago thanks!

sergio-fry avatar Oct 25 '22 05:10 sergio-fry