diff --git a/CHANGELOG.md b/CHANGELOG.md index 446d42aec..ae2190fe9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/pybricks/util_pb/pb_task.c b/pybricks/util_pb/pb_task.c index a1a43d072..839274a95 100644 --- a/pybricks/util_pb/pb_task.c +++ b/pybricks/util_pb/pb_task.c @@ -3,6 +3,7 @@ #include #include +#include #include "py/mpconfig.h" #include "py/mperrno.h" @@ -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 }