TypeError: emit() got an unexpected keyword argument 'broadcast' #1972
Answered
by
miguelgrinberg
Miniontoby
asked this question in
Q&A
-
Hey guys, With Version: Code that could reproduce the error: from flask import Flask
from flask_socketio import SocketIO
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
app = Flask(__name__, static_url_path='/static')
socketio = SocketIO(app)
executors = {'default': ThreadPoolExecutor(16), 'processpool': ProcessPoolExecutor(4)}
sched = BackgroundScheduler(timezone='Asia/Seoul', executors=executors)
sensordata = {"Temperature": 0, "Humidity": 0, "Pressure": 0}
def getsensordata():
global sensordata
# I do get the data in a different way, but just to have a working code for you to test
sensordata = {"Temperature":round(20.12, 2) , "Humidity":round(50.10, 2) , "Pressure":round(1012.12, 2)}
socketio.emit('updateSensorData', sensordata, broadcast=True)
sched.add_job(getsensordata, 'interval', minutes=2)
if __name__ == "__main__":
sched.start()
socketio.run(app, host='0.0.0.0', port=5000)
sched.shutdown() Full Error message: Job "getsensordata (trigger: date[2023-04-15 10:58:16 CEST], next run at: 2023-04-15 10:58:16 CEST)" raised an exception
Traceback (most recent call last):
File "/home/pi/flasks/flask_env/lib/python3.7/site-packages/apscheduler/executors/base.py", line 125, in run_job
retval = job.func(*job.args, **job.kwargs)
File "app.py", line 364, in getsensordata
socketio.emit('updateSensorData', sensordata, broadcast=True)
File "/home/pi/flasks/flask_env/lib/python3.7/site-packages/flask_socketio/__init__.py", line 463, in emit
skip_sid=skip_sid, callback=callback, **kwargs)
TypeError: emit() got an unexpected keyword argument 'broadcast' Also to note: I didn't make the original code! I am just using and improving it! So yeah be sure to keep that in mind |
Beta Was this translation helpful? Give feedback.
Answered by
miguelgrinberg
Apr 17, 2023
Replies: 1 comment 5 replies
-
The error tells you what's wrong. You are passing |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try removing the bad argument.