From 37279e270547293ac284dbedc53b90d24bd978db Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Sun, 27 Nov 2016 10:44:03 -0800 Subject: [PATCH] Do not call init_app when an app or message_queue aren't given Fixes #367 --- flask_socketio/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/flask_socketio/__init__.py b/flask_socketio/__init__.py index a506d504..2180d3c1 100644 --- a/flask_socketio/__init__.py +++ b/flask_socketio/__init__.py @@ -127,8 +127,16 @@ def __init__(self, app=None, **kwargs): self.namespace_handlers = [] self.exception_handlers = {} self.default_exception_handler = None - if app is not None or len(kwargs) > 0: + # We can call init_app when: + # - we were given the Flask app instance (standard initialization) + # - we were not given the app, but we were given a message_queue + # (standard initialization for auxiliary process) + # In all other cases we collect the arguments and assume the client + # will call init_app from an app factory function. + if app is not None or 'message_queue' in kwargs: self.init_app(app, **kwargs) + else: + self.server_options.update(kwargs) def init_app(self, app, **kwargs): if app is not None: