-
Notifications
You must be signed in to change notification settings - Fork 229
remote/client: no block in async console, loop even on unavailable resource #935
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
remote/client: no block in async console, loop even on unavailable resource #935
Conversation
Codecov Report
@@ Coverage Diff @@
## master #935 +/- ##
========================================
- Coverage 56.8% 56.7% -0.1%
========================================
Files 149 149
Lines 11091 11097 +6
========================================
Hits 6301 6301
- Misses 4790 4796 +6
Continue to review full report at Codecov.
|
|
Tested-by: Kevin Hilman khilman@baylibre.com |
|
We've stumbled upon blocking code called from async code. So let's not merge this yet, I'll come back with another version later. |
In certain situations it makes sense to specify a timeout of 0, e.g. if no blocking sleeps are desired in a method that awaits some condition. Let's add an easy way to allow an instant timeout by considering zero a valid value for timeouts. Signed-off-by: Bastian Krause <bst@pengutronix.de>
d662dcd to
d7ac4bb
Compare
d7ac4bb to
7737dba
Compare
|
The blocking wait for the @khilman Please test :) |
…source `labgrid-client console --loop` should keep trying to connect to the console even if the serial port is currently unvailable. The console method is declared async because it needs to handle crossbar communication with the coordinator concurrently, see [1] (e.g. place kicks, resouces becoming available). Until now it only tries again if microcom comes back with a return code != 0. But in case the resource is unavailable, labgrid bails out early because target.get_resource() raises a NoResourceFoundError. Calling target.get_resource() waits until the resources are available by default. This is done in a blocking poll()/time.sleep() loop until a timeout is reached allowing no crossbar communication in the meantime. This again means changes in resource availability we wait for cannot arrive. So there is no point in waiting for them at all. Fix that by awaiting the NetworkSerialPort resource while allowing other tasks to run when --loop is given. Afterwards "wait" for the NetworkSerialPort for 0 seconds. This either succeeds or a NoResourceFoundError is raised, both happens instantly. [1] 19757a1 ("remote/client: close console connection on place release") Signed-off-by: Bastian Krause <bst@pengutronix.de>
7737dba to
2230536
Compare
|
Fixed |
|
I tested this, and it works OK the first time (e.g. if board is powered off when However, if the board is then powered off, then Ideally, |
…ilability PR labgrid-project#935 added async waiting for the NetworkSerialPort. This makes `labgrid-client console --loop` work as long as the resource changes from being unavailable to being available. It does not work vice versa, however: the resources are not being updated before being checked for availability. The code inside the while loop does not run in this case. This makes the subsequent `target.await_resources()` raise a NoResourceFoundError which is not handled anywhere causing an error message and exit of labgrid-client despite being called with ``--loop``. Fix that by updating the resources before checking the resource's availability. `labgrid-client console --loop` will now loop even if the NetworkSerialPort changes from being available to unavailable. Fixes: 2230536 ("remote/client: no block in async console, loop even on unavailable resource") Signed-off-by: Bastian Krause <bst@pengutronix.de>
…ilability PR labgrid-project#935 added async waiting for the NetworkSerialPort. This makes `labgrid-client console --loop` work as long as the resource changes from being unavailable to being available. It does not work vice versa, however: the resources are not being updated before being checked for availability. The code inside the while loop does not run in this case. This makes the subsequent `target.await_resources()` raise a NoResourceFoundError which is not handled anywhere causing an error message and exit of labgrid-client despite being called with ``--loop``. Fix that by updating the resources before checking the resource's availability. `labgrid-client console --loop` will now loop even if the NetworkSerialPort changes from being available to unavailable. Fixes: 2230536 ("remote/client: no block in async console, loop even on unavailable resource") Signed-off-by: Bastian Krause <bst@pengutronix.de>
Description
labgrid-client console --loopshould keep trying to connect to the console even if the serial port is currently unvailable.The console method is declared async because it needs to handle crossbar communication with the coordinator concurrently, see [1] (e.g. place kicks, resouces becoming available).
Until now it only tries again if microcom comes back with a return code != 0. But in case the resource is unavailable, labgrid bails out early because
target.get_resource()raises aNoResourceFoundError.Calling
target.get_resource()waits until the resources are available by default. This is done in a blockingpoll()/time.sleep()loop until a timeout is reached allowing no crossbar communication in the meantime. This again means changes in resource availability we wait for cannot arrive. So there is no point in waiting for them at all.Fix that by awaiting the
NetworkSerialPortresource while allowing other tasks to run when--loopis given. Afterwards "wait" for theNetworkSerialPortfor 0 seconds. This either succeeds or aNoResourceFoundErroris raised, both happens instantly. To make this work, instantTimeout(0.0)is now allowed.[1] 19757a1 ("remote/client: close console connection on place release")
Checklist
Fixes #926