Skip to content

start_polling(), no clean way to exit? (etc) #209

@zefoo

Description

@zefoo

A few questions numbered for easy reference:

  1. If I am using virtualenv, and I'm activated in the environment, and if I run my code via python -m myteleapp (code nearly identical to https://github.com/python-telegram-bot/python-telegram-bot/blob/master/examples/echobot2.py ) ... which starts polling, I can't seem to exit out of polling with ctrl+c. Only way is to kill -9 my app and I don't think this is good for a shutdown. Is there any other way to break out of start_polling()? Perhaps I am doing something wrong.
  2. Or, is there a way to shutdown start_polling if I send the bot a specific message (which I would valid against a certain chat_id)? I tried sys.exit(0) in echo-like function from here https://github.com/python-telegram-bot/python-telegram-bot/blob/master/examples/echobot2.py
  3. Does start_polling() poll every second? Or what's the delay? It looks like default is 0 from the code. Does that mean that it's immediate? This is partly why I went with webhooks, I thought it would be quicker, but this may be my misunderstanding.
  4. The reason I'm wanting to break out of start_polling() is because if I import another mod from my echo-like module, and if I update this other module that's included, I want to make sure start_polling() calls functions with the latest code. I believe I have to do this, I don't believe start_polling() would account for updates to code alone (since the process would stay active).

Thank you.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions