Move code from mqtt __init__.py into separate modules

master
esensar 2018-10-06 13:54:49 +02:00
parent df874fee6c
commit b83a6cf70e
3 changed files with 20 additions and 20 deletions

View File

@ -31,7 +31,7 @@ def setup_blueprints(app):
from .devices.blueprint import devices_bp
from .dashboards.blueprint import dashboard_bp
from .api import api_bp
from .mqtt import mqtt_bp
from .mqtt.blueprint import mqtt_bp
app.register_blueprint(accounts_bp)
app.register_blueprint(devices_bp)

View File

@ -1,19 +0,0 @@
import atexit
from flask import Blueprint
from .mqtt_client import MqttClient
mqtt_bp = Blueprint('mqtt', __name__)
# Setup
@mqtt_bp.record
def __on_blueprint_setup(setup_state):
MqttClient.setup(setup_state.app)
# When app dies, stop mqtt connection
def on_stop():
MqttClient.tear_down()
atexit.register(on_stop)

View File

@ -0,0 +1,19 @@
import atexit
from flask import Blueprint
from .mqtt_client import MqttClient
mqtt_bp = Blueprint('mqtt', __name__)
# Setup
@mqtt_bp.record
def __on_blueprint_setup(setup_state):
MqttClient.setup(setup_state.app)
# When app dies, stop mqtt connection
def on_stop():
MqttClient.tear_down()
atexit.register(on_stop)