Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions labgrid/remote/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from .. import Target, target_factory
from ..util.proxy import proxymanager
from ..util.helper import processwrapper
from ..util import atomic_replace
from ..util import atomic_replace, Timeout
from ..driver import Mode

txaio.config.loop = asyncio.get_event_loop()
Expand Down Expand Up @@ -838,10 +838,20 @@ def digital_io(self):
elif action == 'low':
drv.set(False)

async def _console(self, place, target, *, logfile=None):
async def _console(self, place, target, timeout, *, logfile=None, loop=False):
name = self.args.name
from ..resource import NetworkSerialPort
resource = target.get_resource(NetworkSerialPort, name=name)
resource = target.get_resource(NetworkSerialPort, name=name, wait_avail=False)

# async await resources
timeout = Timeout(timeout)
while not resource.avail and (loop or not timeout.expired):
target.update_resources()
await asyncio.sleep(0.1)

# use zero timeout to prevent blocking sleeps
target.await_resources([resource], timeout=0.0)

host, port = proxymanager.get_host_and_port(resource)

# check for valid resources
Expand Down Expand Up @@ -883,7 +893,8 @@ async def _console(self, place, target, *, logfile=None):

async def console(self, place, target):
while True:
res = await self._console(place, target, logfile=self.args.logfile)
res = await self._console(place, target, 10.0, logfile=self.args.logfile,
loop=self.args.loop)
if res:
break
if not self.args.loop:
Expand Down
2 changes: 1 addition & 1 deletion labgrid/util/timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Timeout:
)

def __attrs_post_init__(self):
if self.timeout <= 0.0:
if self.timeout < 0.0:
raise ValueError("timeout must be positive")
self._deadline = time.monotonic() + self.timeout

Expand Down