telepot
telepot copied to clipboard
flask example working with nginx and wsgi
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"}}'
Hi! I confirm. message_loop() with source queue not working with wsgi.
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.
Same here, DelegatorBot doesn't seems to work.
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. :-)
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.
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).
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.