Skip to content

Commit

Permalink
pybricks/util_pb/pb_task: Don't wait for cancel on shutdown.
Browse files Browse the repository at this point in the history
Fixes pybricks/support#814 so the user can at
least turn the hub off without removing the batteries.
  • Loading branch information
laurensvalk committed Dec 7, 2022
1 parent 3e50334 commit 153d76e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
calling `super().__init(...)` on uninitialized objects ([support#777]).
- Reverted Pybricks Code stop button raises `SystemAbort` instead of
`SystemExit` ([support#834]).
- Fixed Technic Hub and City Hub sometimes not shutting down when a Bluetooth
operation is busy ([support#814]).

[support#777]: https://github.com/pybricks/support/issues/777
[support#805]: https://github.com/pybricks/support/issues/805
[support#834]: https://github.com/pybricks/support/issues/814
[support#826]: https://github.com/pybricks/support/issues/826
[support#834]: https://github.com/pybricks/support/issues/834

Expand Down
3 changes: 2 additions & 1 deletion pybricks/util_pb/pb_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <pbio/error.h>
#include <pbio/task.h>
#include <pbsys/status.h>

#include "py/mpconfig.h"
#include "py/mperrno.h"
Expand Down Expand Up @@ -41,7 +42,7 @@ void pb_wait_task(pbio_task_t *task, mp_int_t timeout) {
} else {
pbio_task_cancel(task);

while (task->status == PBIO_ERROR_AGAIN) {
while (task->status == PBIO_ERROR_AGAIN && !pbsys_status_test(PBIO_PYBRICKS_STATUS_SHUTDOWN_REQUEST)) {
MICROPY_VM_HOOK_LOOP
}

Expand Down

0 comments on commit 153d76e

Please sign in to comment.