Skip to content
New issue

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

Problem when the app is in a package #69

Open
white-gecko opened this issue Nov 26, 2018 · 0 comments
Open

Problem when the app is in a package #69

white-gecko opened this issue Nov 26, 2018 · 0 comments

Comments

@white-gecko
Copy link
Contributor

white-gecko commented Nov 26, 2018

I've placed my app in a package like that:

- package/
  |- __init__.py
  -- echo.py

The code of echo.py is

from flask import Flask
from flask_uwsgi_websocket import GeventWebSocket

app = Flask(__name__.split('.')[0])

print("name is: {}".format(__name__.split('.')[0]))
print(app.name)
print(app.import_name)

websocket = GeventWebSocket(app)

@websocket.route('/echo')
def echo(ws):
    while True:
        msg = ws.receive()
        ws.send(msg)

@app.route('/hello')
def hallo():
    return 'Hello'

if __name__ == '__main__':
    app.run(gevent=100)

As recommended in the flask docu http://flask.pocoo.org/docs/1.0/api/ I use app = Flask(__name__.split('.')[0]) for the name.
But flask_uwsgi_websocket will generate the following uwsgi call:

Running: /home/me/.virtualenvs/env/bin/uwsgi --http localhost:5000 --http-websockets --gevent 100 --master  --virtualenv /home/me/.virtualenvs/env --wsgi echo:app

which results in ModuleNotFoundError: No module named 'echo'

Instead of:

Running: /home/me/.virtualenvs/env/bin/uwsgi --http localhost:5000 --http-websockets --gevent 100 --master  --virtualenv /home/me/.virtualenvs/env --wsgi package.echo:app

Starting uwsgi directly with this command works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant