Giter Site home page Giter Site logo

Comments (5)

JeffLIrion avatar JeffLIrion commented on August 22, 2024 1

FYI:

This device is rather resource constrained and is in some instances rather slow at responding to ADB commands (including when using the ADB binary directly, not involving adb_shell)

https://www.home-assistant.io/integrations/androidtv/#androidtvlearn_sendevent-for-faster-adb-commands

from adb_shell.

JeffLIrion avatar JeffLIrion commented on August 22, 2024

I admit that the timeouts are confusing, I'll see if I can clean that up. But I don't think this is a bug...

class _AdbTransactionInfo(object): # pylint: disable=too-few-public-methods
"""A class for storing info and settings used during a single ADB "transaction."
Note that if ``timeout_s`` is not ``None``, then:
::
self.transport_timeout_s <= self.read_timeout_s <= self.timeout_s
If ``timeout_s`` is ``None``, the first inequality still applies.

def __init__(self, local_id, remote_id, transport_timeout_s=None, read_timeout_s=constants.DEFAULT_READ_TIMEOUT_S, timeout_s=None):
self.local_id = local_id
self.remote_id = remote_id
self.timeout_s = timeout_s
self.read_timeout_s = read_timeout_s if self.timeout_s is None else min(read_timeout_s, self.timeout_s)
self.transport_timeout_s = self.read_timeout_s if transport_timeout_s is None else min(transport_timeout_s, self.read_timeout_s)

Also note that the hack seems to fail if the user modifies adb_shell.constants.DEFAULT_READ_TIMEOUT_S

First of all, you shouldn't modify that -- it's supposed to be a constant, hence the constants.py module and the all caps name.

Second, I think you would need to modify adb_shell.adb_device.constants.DEFAULT_READ_TIMEOUT_S due to the way the imports are performed. But again, you shouldn't do this.

But most of all, you shouldn't need this workaround in the first place. Try providing all three timeout parameters to the shell() method and see if that fixes the problem. You can use the same value for all three.

from adb_shell.

jvmk avatar jvmk commented on August 22, 2024

Hi Jeff,

I admit that the timeouts are confusing, I'll see if I can clean that up. But I don't think this is a bug...

class _AdbTransactionInfo(object): # pylint: disable=too-few-public-methods
"""A class for storing info and settings used during a single ADB "transaction."
Note that if ``timeout_s`` is not ``None``, then:
::
self.transport_timeout_s <= self.read_timeout_s <= self.timeout_s
If ``timeout_s`` is ``None``, the first inequality still applies.

def __init__(self, local_id, remote_id, transport_timeout_s=None, read_timeout_s=constants.DEFAULT_READ_TIMEOUT_S, timeout_s=None):
self.local_id = local_id
self.remote_id = remote_id
self.timeout_s = timeout_s
self.read_timeout_s = read_timeout_s if self.timeout_s is None else min(read_timeout_s, self.timeout_s)
self.transport_timeout_s = self.read_timeout_s if transport_timeout_s is None else min(transport_timeout_s, self.read_timeout_s)

Yes, it might just be that I misunderstood what timeout values are supposed to trump others :). I (incorrectly?) assumed that the timeouts provided to the AdbDeviceTcp constructor and/or the connect() call would apply for .shell() calls if I omitted the timeout parameters when calling .shell().

Also note that the hack seems to fail if the user modifies adb_shell.constants.DEFAULT_READ_TIMEOUT_S

First of all, you shouldn't modify that -- it's supposed to be a constant, hence the constants.py module and the all caps name.

Second, I think you would need to modify adb_shell.adb_device.constants.DEFAULT_READ_TIMEOUT_S due to the way the imports are performed. But again, you shouldn't do this.

Yes, I realize I shouldn't be modifying these constants. I did this as a last resort because I didn't understand why the timeout I specified in the AdbDeviceTcp constructor and connect() call didn't come into effect.

But most of all, you shouldn't need this workaround in the first place. Try providing all three timeout parameters to the shell() method and see if that fixes the problem. You can use the same value for all three.

Makes sense, I'll try this out, cheers.

Thanks again,
Janus

from adb_shell.

JeffLIrion avatar JeffLIrion commented on August 22, 2024

Try providing all three timeout parameters to the shell() method and see if that fixes the problem. You can use the same value for all three.

Did that work?

from adb_shell.

jvmk avatar jvmk commented on August 22, 2024

Try providing all three timeout parameters to the shell() method and see if that fixes the problem. You can use the same value for all three.

Did that work?

Hi Jeff,

Yes, I just verified that if I set all 3 timeouts in .shell() to 4.0, the timeout does become 4.0 seconds as expected:

adb_shell.exceptions.TcpTimeoutException: Reading from <IP>:<PORT> timed out (4.0 seconds)

Thanks for guiding me to a cleaner solution!

Best,
Janus

from adb_shell.

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.