the docs only shows how to start but it does not say anything about stopping the workers? is it necessary? if so, how?
I cant seem to find anything to close it
docs: https://flask-dramatiq.readthedocs.io/en/latest/
>Solution :
In Flask-Dramatiq, you don’t necessarily need to remove or stop the workers manually. When you start the workers using flask_dramatiq.Dramatiq, they will continue running until you stop the Flask application.
You can stop the Flask application in a number of ways, such as using the Ctrl + C command or by programmatically stopping the Flask application using the app_context().push() method.
When the Flask application is stopped, the workers started by flask_dramatiq.Dramatiq will automatically be terminated.
If you want to programmatically stop the workers, you can use the dramatiq.broker.Broker.join() method. This method will block the current thread until all tasks have finished processing and all workers have exited:
from flask import Flask
import dramatiq
from flask_dramatiq import Dramatiq
app = Flask(__name__)
dramatiq_broker = dramatiq.get_broker()
dramatiq = Dramatiq(app)
dramatiq_broker.start()
dramatiq.flush_join()
dramatiq_broker.join()
In the code above, dramatiq_broker.start() starts the workers, and dramatiq_broker.join() stops the workers. The dramatiq.flush_join() method blocks the current thread until all tasks have been processed before calling dramatiq_broker.join().