Avoid asyncore race condition on write availability

This commit is contained in:
Tyler Hobbs
2014-07-08 17:13:27 -05:00
parent 60ded354a9
commit 9dc31d00e8
2 changed files with 8 additions and 7 deletions

View File

@@ -38,6 +38,8 @@ Bug Fixes
* Avoid UnicodeDecodeError when query string is unicode (PYTHON-76)
* Correctly capture dclocal_read_repair_chance for tables and
use it when generating CREATE TABLE statements (PYTHON-84)
* Avoid race condition with AsyncoreConnection that may cause messages
to fail to be written until a new message is pushed
2.0.2
=====

View File

@@ -262,12 +262,12 @@ class AsyncoreConnection(Connection, asyncore.dispatcher):
def handle_write(self):
while True:
try:
with self.deque_lock:
with self.deque_lock:
try:
next_msg = self.deque.popleft()
except IndexError:
self._writable = False
return
except IndexError:
self._writable = False
return
try:
sent = self.send(next_msg)
@@ -318,8 +318,7 @@ class AsyncoreConnection(Connection, asyncore.dispatcher):
with self.deque_lock:
self.deque.extend(chunks)
self._writable = True
self._writable = True
def writable(self):
return self._writable