From f0ae464128f0165a67d4399901a51a7248ccde6c Mon Sep 17 00:00:00 2001 From: Guillaume Jeusel Date: Fri, 7 Feb 2020 16:17:00 +0100 Subject: [PATCH] [IMP] don't remove the empty_backend but rather filter it --- flask_melodramatiq/lazy_broker.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/flask_melodramatiq/lazy_broker.py b/flask_melodramatiq/lazy_broker.py index 7cfddc2..5c35bbf 100644 --- a/flask_melodramatiq/lazy_broker.py +++ b/flask_melodramatiq/lazy_broker.py @@ -138,7 +138,10 @@ def init_app(self, app): """ if self.__stub: - self.__options['middleware'] = self.__stub.middleware + self.__options['middleware'] = [ + m for m in self.__stub.middleware + if m is not self.__empty_backend + ] configuration = self.__get_configuration(app) self.__stub.close() self.__stub = None @@ -150,10 +153,6 @@ def init_app(self, app): # Instanciate dramatiq Broker broker = self._dramatiq_broker_factory(**options) - # Pull out empty backend from middleware - if self.__empty_backend in broker.middleware: - broker.middleware.remove(self.__empty_backend) - # Add Flask App Context Middleware broker.add_middleware(AppContextMiddleware(app))