-
-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to start periodically task inside falcon? #162
Comments
@sergio-fry I guess this is no longer relevant but let me just leave it here. https://github.com/socketry/timers
|
We can probably change this so that the config.ru is constructed within the top level async block... let me check. |
@webgago thanks! |
@ioquatix some time has passed since the original question was asked, but still... Is there a way to spawn an async task that operates concurrently in relation to Falcon's spawned request-related tasks? The code below seemingly achieves the goal but is it possible to do that with async only? def subscribe
Thread.new do
@redis.subscribe("app_#{APP_ID}") do |on|
on.message do |channel, message|
LOGGER.debug "message on channel #{channel}: #{message}"
MUTEX.synchronize { SubService.new(channel, deserialize(message)) }
end
end
end
end The thread in the code above is instantiated when the application starts and keeps waiting for sub messages. When a message is received, the thread intervenes between whatever Falcon is doing. Is it possible to get this behavior without threads? Perhaps, by adding this as a task to Falcon's main event-loop? How can I achieve that? |
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?The text was updated successfully, but these errors were encountered: