We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I just try to return the rc from handle_connect using asyncio, but failed the code:
rc
handle_connect
@app.route('/connect/', methods=['POST','GET']) async def make_connect(): rc_status=-1 connect_future = asyncio.Future() data = request.get_json()['data'] print(data) app.config['MQTT_BROKER_URL'] = data['host'] app.config['MQTT_BROKER_PORT'] = int(data['port']) if data['usr'] != '': app.config['MQTT_USERNAME'] = data['usr'] app.config['MQTT_PASSWORD'] = data['password'] app.config['MQTT_KEEPALIVE'] = 60 app.config['MQTT_TLS_ENABLED'] = False print(connect_future.done()) mqtt.init_app(app) @mqtt.on_connect() def handle_connect(client, userdata, flags, rc): if rc == 0: print('Connected successfully') # print(rc) print(connect_future.done()) connect_future.set_result(rc) print(connect_future.done()) result = await connect_future rc_status = result return { 'rc_status':rc_status }
the output in terminal:
{'host': '127.0.0.1', 'port': '1883', 'usr': '', 'password': ''} False Connected successfully False True
so i think the connect_future is correctly set but something wrong happened also i can't use ctrl-C to terminate the flask app correctly
connect_future
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I just try to return the
rc
fromhandle_connect
using asyncio, but failedthe code:
the output in terminal:
so i think the
connect_future
is correctly set but something wrong happenedalso i can't use ctrl-C to terminate the flask app correctly
The text was updated successfully, but these errors were encountered: