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
Allowing WaitGroup.add(count) to accept a value to be added to WaitGroup.wait_count seems to be inconsistent with WaitGroup.done() which only ever decrements the count by 1.
A thread could be started and the code erroneously adds a count > 1 to the WaitGroup by misusing the parameters. The main thread will never end (the WaitGroup.wait() continues to loop) because the child threads never reduce the count to zero. I've tried this in the concurrent file search example.
def file_search(root, filename, wait_group):
print("Searching in:", root)
for file in os.listdir(root):
full_path = join(root, file)
if filename in file:
mutex.acquire()
matches.append(full_path)
mutex.release()
if isdir(full_path):
wait_group.add(2)
t = Thread(target=file_search, args=([full_path, filename, wait_group]))
t.start()
wait_group.done()
Of course this is simply a programmer problem, unlikely to happen, but looks inconsistent for the example. Unfortunately this is baked into your video.
The text was updated successfully, but these errors were encountered:
Allowing
WaitGroup.add(count)
to accept a value to be added toWaitGroup.wait_count
seems to be inconsistent withWaitGroup.done()
which only ever decrements the count by 1.A thread could be started and the code erroneously adds a count > 1 to the WaitGroup by misusing the parameters. The main thread will never end (the
WaitGroup.wait()
continues to loop) because the child threads never reduce the count to zero. I've tried this in the concurrent file search example.Of course this is simply a programmer problem, unlikely to happen, but looks inconsistent for the example. Unfortunately this is baked into your video.
The text was updated successfully, but these errors were encountered: