Skip to content
This repository has been archived by the owner on Jun 2, 2019. It is now read-only.

flask example working with nginx and wsgi #198

Open
molavy opened this issue Dec 21, 2016 · 7 comments
Open

flask example working with nginx and wsgi #198

molavy opened this issue Dec 21, 2016 · 7 comments

Comments

@molavy
Copy link

molavy commented Dec 21, 2016

i try run flask example with wsgi and nginx
so i changed sys.args to manual set variable.
telegram never response ,
i see 200 in nginx response and when i open url in browser i see OK
i also add print line before
print(request.data)
update_queue.put(request.data) # pass update to bot

but i never get telegram response to user

b'{"update_id":651538238,\n"message":{"message_id":103,"from":{"id":259792113,"first_name":"ho","last_name":"ra","username":"rrm"},"chat":{"id":259792113,"first_name":"ho","last_name":"ra","username":"rrm","type":"private"},"date":1482353453,"text":"lj"}}'

@molavy molavy changed the title flask example working with wsgi flask example working with nginx and wsgi Dec 21, 2016
@DanielSerdyukov
Copy link

Hi! I confirm. message_loop() with source queue not working with wsgi.

@nickoala
Copy link
Owner

Please confirm, are you guys using uWSGI?

I don't have much experience with wsgi, uwsgi, or nginx. but a web search seems to link nginx with uwsgi (with a 'u' in front). That's why I want to confirm. Thanks.

@naweiss
Copy link

naweiss commented Dec 4, 2017

Same here, DelegatorBot doesn't seems to work.

@funnyflowerpot
Copy link

funnyflowerpot commented Mar 1, 2018

Hi @nickoala, I can confirm this problem for uWSGI. I tried this example, but the request.data that I webhook.feed() does not seem to get forwarded to MessageCounter.

I'm using PythonAnywhere, which features a tutorial for telepot without DelegatorBot. Somebody on their forums tried the same thing and apparently a staff member claimed (currently last post in that thread), that this approach won't work due to telepot's need for an own event-handling loop.

PythonAnywhere uses uWSGI and nginx. The log-files for my webapp on PythonAnywhere start with these lines:

2018-01-28 14:22:21 *** Starting uWSGI 2.0.14 (64bit) on [Sun Jan 28 14:22:18 2018] ***
2018-01-28 14:22:21 compiled with version: 5.4.0 20160609 on 22 November 2017 21:24:09
2018-01-28 14:22:21 os: Linux-4.4.0-109-generic #132-Ubuntu SMP Tue Jan 9 19:52:39 UTC 2018

Do you think DelegatorBot can be made working with uWSGI? Any ideas appreciated, happy to help, thanks. :-)

@funnyflowerpot
Copy link

Update: In the log files I have just seen a line saying:

*** Python threads support is disabled. You can enable it with --enable-threads ***

As telepot uses threads, this might be the cause of the problem.

@nickoala
Copy link
Owner

nickoala commented Mar 2, 2018

Yes, DelegatorBot in telepot's traditional version uses threads. Any environments that disallow Python threads would not be able to run DelegatorBot.

I personally don't use PythonAnywhere, so can't suggest much here. Either get it to allow threads there, or use telepot's async version, which is based on asyncio (not threads).

@funnyflowerpot
Copy link

funnyflowerpot commented Mar 2, 2018

Thanks for the quick reply. Threads are available on PythonAnywhere to non-free accounts only, unfortunately. asyncio raised some hopes, but according to a post from 2015 the used uWSGI implementation doesn't support this either.
As the folks at PythonAnywhere suggest to use telepot, I will bring this issue to their attention.
Edit: The thread in PythonAnywhere's forums.

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

No branches or pull requests

5 participants