pb_client ¶
Client library for the Pybricks service.
The public surface is deliberately shaped so that structured concurrency cannot
be violated from outside: anything producing ongoing events is an async context
manager yielding an async iterator, and no function takes a timeout
argument. Callers scope cancellation with
fail_after or
move_on_after instead.
Modules¶
autostart-- Starting a service on demand.compile-- Compiling Python for a hub.errors-- Errors raised by the client library.models-- What the service says, as types rather than as dictionaries.service-- Talking to the service.stdio-- What a hub says while a program is running on it.
Classes¶
Choice-- The hub that commands act on when none is named.CompileError-- The program could not be compiled.CompiledProgram-- A compiled program, not yet in the form the hub stores.DeviceInfo-- A hub seen while scanning.Downloaded-- Where a program ended up on the hub.HubInfo-- A connected hub.Output-- A chunk of what the program on the hub printed.PbClientError-- Base class for every error this library raises.Service-- A connected service.ServiceInfo-- What the service reports about itself.ServiceStartError-- A service was started but never became reachable.ServiceTooOld-- The running service does not have a feature this client needs.ServiceUnavailable-- No service is running and starting one was not permitted.State-- The hub's connection changed state.Status-- What the hub currently reports about itself.UnusableAdapter-- A Bluetooth adapter a scan could not use, and why.
Functions¶
compile_program-- Compile a script and every module of its own that it imports.compile_script-- Compile a script into a program, for a hub whose profile is not known.compile_source-- Compile Python source into a program the hub can run.connect-- Connect to the service for the duration of the block.describe_compiler-- Return the compiler path and its architecture, for the startup log.
Attributes¶
REPL_PROGRAM_ID-- The program id the hub reports while its interpreter is what is running.SOURCE_NAME-- The file name to record for source that did not come from a file.