Runtime and scheduling
Core interfaces
The SDK root owns the lifecycle of all configured capabilities. Use glove() to access the Glove domain. Constructor parameters are in Configuration reference.
Sdk.glove()
Enters the glove functionality.
Type
Sdk.glove() -> GloveReturns
Details
- Call conditions: SDK not closed.
Errors
ClosedHandleError, capability unavailable.
Sdk.start()
Start devices and capabilities in this object’s scope.
Type
Sdk.start() -> NoneReturns
None.
Details
- Call conditions: After preparing data reading and subscription.
Errors
- Connection, identity, data stream or lifecycle errors.
See also
Sdk.update()
Perform one SDK scheduling pass and return its update result.
Type
Sdk.update() -> UpdateResultReturns
Details
- Call conditions: Started and no other run mode in use.
- Call
sleep()on each result only once; see Runtime for run modes and wait semantics.
Errors
LifecycleError.
Example
sdk is an SDK with its devices and targets already configured. Call sleep() once per update result, and do not start a background runner at the same time.
from qnbot_sdk import SleepResult
import time
sdk.start()
try:
for _ in range(100):
update = sdk.update()
if update.sleep() is SleepResult.NO_TASKS:
time.sleep(0.01)
finally:
sdk.close()Complete example: manual_runtime.py.
See also
Sdk.run_forever()
Advance SDK scheduling on the current thread until stopped.
Type
Sdk.run_forever() -> NoneReturns
None.
Details
- Call conditions: Started and no other run mode in use.
- Blocks the current thread; do not mix with background execution or manual
update().
Errors
LifecycleError.
Example
sdk is an SDK with its devices and targets already configured. This call occupies the current thread. See the complete example for shutdown handling.
sdk.start()
try:
sdk.run_forever()
finally:
sdk.close()Complete example: foreground_runtime.py.
See also
Sdk.run_background()
Start background scheduling so the current thread can continue.
Type
Sdk.run_background() -> NoneReturns
None.
Details
- Call conditions: Started and no other run mode in use.
- Mutually exclusive with
run_forever()and manualupdate(). Request stop and calljoin()to finish.
Errors
LifecycleError, background running errors.
Example
sdk is an SDK with its devices and targets already configured. The application thread remains available. Request shutdown, join the thread, and then close the scope.
import time
sdk.start()
sdk.run_background()
try:
time.sleep(1.0)
finally:
sdk.request_stop()
sdk.join()
sdk.close()Complete example: background_runtime.py.
See also
Sdk.request_stop()
Request that the current run loop stop.
Type
Sdk.request_stop() -> NoneReturns
None.
Errors
LifecycleError.
See also
Sdk.join()
Wait for the background thread and report background runtime errors.
Type
Sdk.join() -> NoneReturns
None.
Details
- Call
request_stop()first. This method reports background errors; do not omit the wait.
Errors
LifecycleError, background errors.
See also
Sdk.stop()
Stop the current scope and disconnect its devices.
Type
Sdk.stop() -> NoneReturns
None.
Details
- The scope can be started again; stopping a device cancels active calibration.
Errors
- Errors during stopping.
See also
Sdk.close()
Close the current scope and release its resources.
Type
Sdk.close() -> NoneReturns
None.
Errors
- Errors during closing; the object becomes invalid after closing.
See also
Sdk.health()
Read the health summary for the current scope.
Type
Sdk.health() -> HealthReturns
Details
- Call conditions: SDK not closed.
Errors
ClosedHandleError.