Wednesday, September 27, 2017

Python thread "daemon" property may hang your console

A little discovery, while playing with some of Adrian's tutorials at Pyimagesearch involving a threaded web camera sampling.

It seems that a thread shouldn't be declared as a "daemon", because after the script ends, a zombie  hangs the console where the Python process is executed.

That's the specific example which was debugged:

From : https://github.com/jrosebr1/imutils/blob/master/imutils/video/webcamvideostream.py

from threading import Thread ...

def start(self):
# start the thread to read frames from the video stream
t = Thread(target=self.update, args=())

t.daemon = False #was True

t.start()
return self


The problem may be platform specific for Windows 10 + Python 3.6.1 (my environment), because other users haven't reported such misbehavior.

No comments :