You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The function is blocking, meaning that once started the routine can't be exited unless the function is stopped. It's possible to stop the function by signalling on the Done channel, which can be passed to the function inside the StatsOpts structure. Theoretically, sending a boolean to the channel should interrupt the function, however when attempting to do so an error is returned that states the channel is closed. It's possible this is an issue with the API itself.
What needs to be done:
Debug the program step by step, and try writing a smaller straight forward code to test the interruption of the function directly.
If the issue is in the API, open an issue on the GitHub of the API itself to report this problem.
Wait for the answer and fix the issue
Try if the same approach of the stopChannel works also for the doneChannel. It depends on how the library handle this channel. So: one channel for all the goroutine that gets closed when done.
It's very likely that the API is the issue here. I've tested it in the simplest way possible, and it still gives me the error. I reported this on the github of the API: fsouza/go-dockerclient#423
@Cerfoglg since they are not replying lets proceed with a different approach to stop the execution of the blocking go routine. We then update this issue and keep it open waiting for the response of for future investigations by our side. Maybe here we found some hints: http://blog.labix.org/2011/10/09/death-of-goroutines-under-control
@VincenzoFerme It appears that the done channel does work in stopping the function, but the Stats function returns an error when stopped instead of quitting gracefully. It's easy to work around that, so the problem is solved now, although it would be nice to not have the function give that error when exiting. I added a comment on the API's issue I opened.
In the stats collector, we are using this golang API for connecting to Docker and retrieving the stats: https://github.com/fsouza/go-dockerclient
In the code, we use this function to retrieve the stats: https://godoc.org/github.com/fsouza/go-dockerclient#Client.Stats
The function is blocking, meaning that once started the routine can't be exited unless the function is stopped. It's possible to stop the function by signalling on the Done channel, which can be passed to the function inside the StatsOpts structure. Theoretically, sending a boolean to the channel should interrupt the function, however when attempting to do so an error is returned that states the channel is closed. It's possible this is an issue with the API itself.
What needs to be done:
Related issues: #1, #4, benchflow/monitors#1,
The text was updated successfully, but these errors were encountered: