Skip to content

Commit

Permalink
Fixed exception not rethrown in webcamvideostream
Browse files Browse the repository at this point in the history
Fixed FATAL: exception not rethrown in webcamvideostream PyImageSearch#237
  • Loading branch information
ShinoAce authored Jan 24, 2021
1 parent c12f153 commit 3390040
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions imutils/video/webcamvideostream.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ def __init__(self, src=0, name="WebcamVideoStream"):

# initialize the thread name
self.name = name

# create a thread
self.thread = None

# initialize the variable used to indicate if the thread should
# be stopped
self.stopped = False

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

def update(self):
Expand All @@ -40,3 +43,7 @@ def read(self):
def stop(self):
# indicate that the thread should be stopped
self.stopped = True
# wait until stream resources are released (producer thread might be still grabbing frame)
if self.thread is not None:
self.thread.join()
# properly handle stop the thread

0 comments on commit 3390040

Please sign in to comment.