telegram_hook | A Telegram log hook for the Logrus logging framework
kandi X-RAY | telegram_hook Summary
kandi X-RAY | telegram_hook Summary
A Telegram log hook for the Logrus logging framework
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of telegram_hook
telegram_hook Key Features
telegram_hook Examples and Code Snippets
Community Discussions
Trending Discussions on telegram_hook
QUESTION
I'm trying to set up python-telegram-bot
library in webhook mode with Django. That should work as follows: on Django startup, I do some initial setting of python-telegram-bot
and get a dispatcher
object as a result. Django listens to /telegram_hook
url and receives updates from Telegram servers. What I want to do next is to pass the updates to the process_update
method of the dispatcher
created on startup. It contains all the parsing logic and invokes callbacks specified during setup.
The problem is that the dispatcher
object needs to be saved globally. I know that global states are evil but that's not really a global state because the dispatcher
is immutable. However, I still don't know where to put it and how to ensure that it will be visible to all threads after setup phase is finished. So the question is how do I properly save the dispatcher
after setup to invoke it from Django's viewset
?
P.S. I know that I could use a built-in web server or use polling or whatever. However, I have reasons to use Django and I anyway would like to know how to deal with cases like that because it's not the only situation I can imagine when I need to store an immutable object created on startup globally.
...ANSWER
Answered 2018-May-15 at 16:16It looks like you need thread safe singleton like this one https://gist.github.com/werediver/4396488 or http://alacret.blogspot.ru/2015/04/python-thread-safe-singleton-pattern.html
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install telegram_hook
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page