Git Product home page Git Product logo

Comments (5)

luckydonald avatar luckydonald commented on June 19, 2024 1

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?

from pytg.

luckydonald avatar luckydonald commented on June 19, 2024

added to documentation in commit 22e5b4b

from pytg.

drr3d avatar drr3d commented on June 19, 2024

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

from pytg.

luckydonald avatar luckydonald commented on June 19, 2024

Your welcome.

from pytg.

luckydonald avatar luckydonald commented on June 19, 2024

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

from pytg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.