esdalmaijer / webcam-eyetracker

Webcam-based pupil-tracker, complete with GUI to perform calibrations.
http://www.pygaze.org/2015/06/webcam-eye-tracker/
GNU General Public License v3.0
294 stars 105 forks source link

Various threads do not close when close() is called #9

Open kenjones21 opened 6 years ago

kenjones21 commented 6 years ago

When close is called, I believe the behavior should be that the various thread processing threads and such are signaled to close. However, if connection with the eyetracker has closed, the _alive event is never unset, and as such the threads just continue to run.

esdalmaijer commented 6 years ago

Could you be more specific? I'm assuming you're referring to the OpenCV codebase, in which the _alive Event is cleared when close is called. Or am I missing something?

Also note that all Processes and Threads are set to deamon, which means they (and their resources) are forcibly closed upon an unexpected exit. This shouldn't happen, as it can leave things in disarray, so feel free to implement a more gracious error-catching.

kenjones21 commented 6 years ago

Sorry for taking so long to get back to you! I am indeed referring to the OpenCV codebase. There is a possibility I'm misunderstanding something, but in the close function in generic.py, the body of the function only runs if self._connected is true. So, for instance, if I enqueue all the images I want to process and close the connection before the images are processed, the threads will never join. I think the thread joining should probably happen regardless of whether the connection was open.