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

Robot is not stoppable #797

Closed
Saied74 opened this issue Jun 12, 2021 · 1 comment
Closed

Robot is not stoppable #797

Saied74 opened this issue Jun 12, 2021 · 1 comment

Comments

@Saied74
Copy link

Saied74 commented Jun 12, 2021

Here is a bit of code from the function (*Robot) Start(args ...interface{}) error starting on line 160 of the file gobot/robot.go. Lines 180 through 183 are:

go func () { r.Work() <- r.done }()

Typically, the function "Work" is an infinite loop. That means that <-done would not be ordinarily reachable. Hence the robot can't be stopped by this signal since the Stop function relies on sending a signal on the r.done channel. That has been my experience in my Raspberry Pi project.

@Saied74
Copy link
Author

Saied74 commented Jun 17, 2021

After some experimentation and research, I decided to abandon using the robot. I put the work function into a go routine and passed it a context with cancel. I have tested it and it seems to work well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant