Commit 7e002e19 authored by Denis Bilenko's avatar Denis Bilenko

fix Channel.put method. Thanks to Alexey Borzenkov.

parent ed31a708
......@@ -418,7 +418,8 @@ class Channel(object):
timeout = 0
waiter = Waiter()
self.putters.append((item, waiter))
item = (item, waiter)
self.putters.append(item)
timeout = Timeout.start_new(timeout, Full)
try:
if self.getters:
......@@ -426,11 +427,17 @@ class Channel(object):
result = waiter.get()
assert result is waiter, "Invalid switch into Channel.put: %r" % (result, )
except:
self.putters.remove(waiter)
self._discard(item)
raise
finally:
timeout.cancel()
def _discard(self, item):
try:
self.putters.remove(item)
except ValueError:
pass
def put_nowait(self, item):
self.put(item, False)
......
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