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

pytg.exceptions.NoResponse #56

Closed
drr3d opened this issue Dec 5, 2015 · 5 comments
Closed

pytg.exceptions.NoResponse #56

drr3d opened this issue Dec 5, 2015 · 5 comments

Comments

@drr3d
Copy link

drr3d commented Dec 5, 2015

Hi there..

first, i really enjoy and appreciate your work,

i've found some issues like i attached the image below bro

dsc_0164

i don't know whats wrong, my connection seem good..

may be i miss something?

thx

@luckydonald
Copy link
Owner

Normally the CLI should response with a success status, indicating whether it did execute the command, or if it failed.
CLI: status_online command

pytg.exceptions.NoResponse:
This Exception means the CLI didn't send any response to that command in time.
This occasionally happens with the status_online command.
Per default the status_online command waits the default timeout specified in Sender.default_answer_timeout which is 1.0 seconds. You may change the timeout of any command with supplying result_timeout=<seconds> in the call.
Also you can surround it with a try block, excepting a NoResponse if you like to ignore it.

Combined example:

try:
    sender.status_online(result_timeout=5)  # wait up to 5 seconds
except NoResponse:  # from pytg.exceptions import NoResponse
    print("CLI did not responded in time")

Some questions, if this happens not only occasionally:

  • How did you start the CLI, manually or with python?
  • If started manually, did you start it with the --json flag?

@luckydonald luckydonald changed the title hi there pytg.exceptions.NoResponse Dec 7, 2015
@luckydonald
Copy link
Owner

added to documentation in commit 22e5b4b

@drr3d
Copy link
Author

drr3d commented Dec 8, 2015

Hi donald,

yes i start the CLI manually with

./telegram-cli -P 6090 -W --json

and i start to learn how to use this package with ping.py, i think the problem was the:

sender.status_online()

so your solutions to add some err handling with:

try:
    sender.status_online(result_timeout=5)  # wait up to 5 seconds
except NoResponse:  # from pytg.exceptions import NoResponse
    print("CLI did not responded in time")

its work like a charm

Thx bro

@luckydonald
Copy link
Owner

Your welcome.

@luckydonald
Copy link
Owner

Honestly I have no Idea why that line fails so often :D

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

No branches or pull requests

2 participants