Commit 10e6643f authored by Denis Bilenko's avatar Denis Bilenko

Semaphore: check that initial value is not negative

parent 2de15323
......@@ -18,6 +18,8 @@ class Semaphore(object):
If not given, value defaults to 1."""
def __init__(self, value=1):
if value < 0:
raise ValueError("semaphore initial value must be >= 0")
self._links = []
self.counter = value
self._notifier = None
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment