From 67e19aad0b7ce13764bb1c7460366392c20fef1f Mon Sep 17 00:00:00 2001 From: Adam Holmberg Date: Mon, 4 May 2015 12:01:16 -0500 Subject: [PATCH] Refactor _callbacks and _push_watchers init to Connection --- cassandra/connection.py | 1 + cassandra/io/asyncorereactor.py | 1 - cassandra/io/eventletreactor.py | 3 --- cassandra/io/geventreactor.py | 3 --- cassandra/io/libevreactor.py | 1 - cassandra/io/twistedreactor.py | 1 - tests/unit/test_connection.py | 3 --- 7 files changed, 1 insertion(+), 12 deletions(-) diff --git a/cassandra/connection.py b/cassandra/connection.py index c1cb08e1..57f5f96a 100644 --- a/cassandra/connection.py +++ b/cassandra/connection.py @@ -194,6 +194,7 @@ class Connection(object): self.is_control_connection = is_control_connection self.user_type_map = user_type_map self._push_watchers = defaultdict(set) + self._callbacks = {} self._iobuf = io.BytesIO() if protocol_version >= 3: self._header_unpack = v3_header_unpack diff --git a/cassandra/io/asyncorereactor.py b/cassandra/io/asyncorereactor.py index 52972b9e..b815d20a 100644 --- a/cassandra/io/asyncorereactor.py +++ b/cassandra/io/asyncorereactor.py @@ -158,7 +158,6 @@ class AsyncoreConnection(Connection, asyncore.dispatcher): Connection.__init__(self, *args, **kwargs) asyncore.dispatcher.__init__(self) - self._callbacks = {} self.deque = deque() self.deque_lock = Lock() diff --git a/cassandra/io/eventletreactor.py b/cassandra/io/eventletreactor.py index 8be3a073..5db0816c 100644 --- a/cassandra/io/eventletreactor.py +++ b/cassandra/io/eventletreactor.py @@ -85,9 +85,6 @@ class EventletConnection(Connection): self._write_queue = Queue() - self._callbacks = {} - self._push_watchers = defaultdict(set) - sockerr = None addresses = socket.getaddrinfo( self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM diff --git a/cassandra/io/geventreactor.py b/cassandra/io/geventreactor.py index 83abd5d8..84285957 100644 --- a/cassandra/io/geventreactor.py +++ b/cassandra/io/geventreactor.py @@ -82,9 +82,6 @@ class GeventConnection(Connection): self._write_queue = Queue() - self._callbacks = {} - self._push_watchers = defaultdict(set) - sockerr = None addresses = socket.getaddrinfo(self.host, self.port, socket.AF_UNSPEC, socket.SOCK_STREAM) for (af, socktype, proto, canonname, sockaddr) in addresses: diff --git a/cassandra/io/libevreactor.py b/cassandra/io/libevreactor.py index 3559c0bf..31c9cd38 100644 --- a/cassandra/io/libevreactor.py +++ b/cassandra/io/libevreactor.py @@ -264,7 +264,6 @@ class LibevConnection(Connection): def __init__(self, *args, **kwargs): Connection.__init__(self, *args, **kwargs) - self._callbacks = {} self.deque = deque() self._deque_lock = Lock() diff --git a/cassandra/io/twistedreactor.py b/cassandra/io/twistedreactor.py index 12a8f530..9b835fe1 100644 --- a/cassandra/io/twistedreactor.py +++ b/cassandra/io/twistedreactor.py @@ -189,7 +189,6 @@ class TwistedConnection(Connection): self.is_closed = True self.connector = None - self._callbacks = {} reactor.callFromThread(self.add_connection) self._loop.maybe_start() diff --git a/tests/unit/test_connection.py b/tests/unit/test_connection.py index 7fc4ed4e..a779e133 100644 --- a/tests/unit/test_connection.py +++ b/tests/unit/test_connection.py @@ -261,10 +261,7 @@ class ConnectionTest(unittest.TestCase): Ensure the following methods throw NIE's. If not, come back and test them. """ c = self.make_connection() - self.assertRaises(NotImplementedError, c.close) - self.assertRaises(NotImplementedError, c.register_watcher, None, None) - self.assertRaises(NotImplementedError, c.register_watchers, None) def test_set_keyspace_blocking(self): c = self.make_connection()