Skip to content

Instantly share code, notes, and snippets.

@pteichman pteichman/
Last active Nov 25, 2019

What would you like to do?
Python WaitGroup (like Go sync.WaitGroup)
import threading # :(
class WaitGroup(object):
"""WaitGroup is like Go sync.WaitGroup.
Without all the useful corner cases.
def __init__(self):
self.count = 0 = threading.Condition()
def add(self, n):
self.count += n
def done(self):
self.count -= 1
if self.count == 0:
def wait(self):
while self.count > 0:

This comment has been minimized.

Copy link

LukasKiederle commented Nov 25, 2019

Nice job. I just needed that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.