Skip to content
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

pybricks/util_pb/pb_task: Don't wait for cancel on shutdown. #129

Merged
merged 1 commit into from
Dec 8, 2022

Conversation

laurensvalk
Copy link
Member

Fixes pybricks/support#814. This also works around things like pybricks/support#567 so the user can at least turn the hub off without removing the batteries.

@laurensvalk laurensvalk added topic: bluetooth Issues involving bluetooth software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) labels Dec 7, 2022
@laurensvalk
Copy link
Member Author

For reproduction, use the script in pybricks/support#567

Copy link
Member

@dlech dlech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some WIP Bluetooth fixes that should help avoid the issues this is working around. But if we want to save that for a later release, this seems like an OK workaround for now.

@@ -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)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a HACK comment here that explains that this is dangerous but is hopefully OK on shutdown. I'm a little concerned about USB hubs though since they don't actually power off on shutdown when the battery is charging, so this could cause hard crashes on those hubs. To avoid that, we would also need to empty any task queues so that we don't try to keep running zombie tasks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hack is only needed on technic / city hub right now, so documenting it as a hack and enabling it only on non-charging hubs could work for now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not against merging BT fixes by the way, we could talk about it tomorrow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable.

Fixes pybricks/support#814 so the user can at
least turn the hub off without removing the batteries.
@laurensvalk laurensvalk merged commit 7d34df4 into master Dec 8, 2022
@laurensvalk laurensvalk deleted the pb-task-shutdown branch December 8, 2022 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
software: pybricks-micropython Issues with Pybricks MicroPython firmware (or EV3 runtime) topic: bluetooth Issues involving bluetooth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Technic Hub can get stuck during shutdown
2 participants