I'm currently testing a socket io app and I'm noticing unusual behavior. In my init python script I'm declaring a function that instantiates a flask object and initializes it via a socketIO instance (which is global) i.e. (assuming all of these files are within the same directory scope):
#/test_app/configs/__init__.py
__socketIO__ = SocketIO()
def create_app(address, port):
app = Flask(__name__, static_url_path='')
app.config.from_pyfile('config.py')
__socketIO__.init_app(app)
return app
in another python script:
#/test_app/run_app.py
from configs import create_app
from configs import __socketIO__ as launch_socket
ip_address = '0, 0, 0, 0'
port = 5000
APP = create_app(ip_address, port)
if __name__ == '__main__':
print 'launching....'
launch_socket.run(APP, debug=True, host=ip_addres, port=port)
Given this, if I run run_app.py, 'launching...' will print twice. Is this behavior typical? Granted I'm still learning my way around socket.io so perhaps I'm missing some point to it. It just seems odd that it initializes twice. Is there a way to circumvent this behavior if it's unnecessary or detrimental?
Thanks!