Skip to content

Commit

Permalink
Fix #11: Rename Connection.wait_closed to .ensure_closed
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Apr 26, 2015
1 parent d34c970 commit 4897b68
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ x.x.x (XXXX-XX-XX)

* Fixed sqlalchemy 1.0.0 support.

* Fix #11: Rename Connection.wait_closed() to .ensure_closed()


0.0.3 (2015-03-10)
^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion aiomysql/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def close(self):
self._reader = None

@asyncio.coroutine
def wait_closed(self):
def ensure_closed(self):
"""Send quit command and then close socket connection"""
if self._writer is None:
# connection has been closed
Expand Down
2 changes: 1 addition & 1 deletion aiomysql/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def clear(self):
with (yield from self._cond):
while self._free:
conn = self._free.popleft()
yield from conn.wait_closed()
yield from conn.ensure_closed()
self._cond.notify()

def close(self):
Expand Down
2 changes: 1 addition & 1 deletion docs/connection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Example::
Close the connection now (rather than whenever `del` is executed).
The connection will be unusable from this point forward.

.. method:: wait_closed()
.. method:: ensure_closed()

A :ref:`coroutine <coroutine>` ends quit command and then closes
socket connection.
Expand Down
2 changes: 1 addition & 1 deletion tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def setUp(self):

def tearDown(self):
for connection in self.connections:
self.loop.run_until_complete(connection.wait_closed())
self.loop.run_until_complete(connection.ensure_closed())
super(AIOPyMySQLTestCase, self).tearDown()

@asyncio.coroutine
Expand Down
6 changes: 3 additions & 3 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ def test_connection_properties(self):
conn.close()

@run_until_complete
def test_connection_double_wait_closed(self):
def test_connection_double_ensure_closed(self):
conn = yield from self.connect(no_delay=True)
self.assertFalse(conn.closed)
yield from conn.wait_closed()
yield from conn.ensure_closed()
self.assertTrue(conn.closed)
yield from conn.wait_closed()
yield from conn.ensure_closed()
self.assertTrue(conn.closed)
10 changes: 5 additions & 5 deletions tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_issue_6(self):
c = yield from conn.cursor()
self.assertEqual(conn.db, 'mysql')
yield from c.execute("select * from user")
yield from conn.wait_closed()
yield from conn.ensure_closed()

@run_until_complete
def test_issue_8(self):
Expand Down Expand Up @@ -369,26 +369,26 @@ def test_issue_114(self):
yield from c.execute("""select @@autocommit;""")
r = yield from c.fetchone()
self.assertFalse(r[0])
yield from conn.wait_closed()
yield from conn.ensure_closed()
yield from conn.ping()
yield from c.execute("""select @@autocommit;""")
r = yield from c.fetchone()
self.assertFalse(r[0])
yield from conn.wait_closed()
yield from conn.ensure_closed()

# Ensure autocommit() is still working
conn = yield from self.connect(charset="utf8")
c = yield from conn.cursor()
yield from c.execute("""select @@autocommit;""")
r = yield from c.fetchone()
self.assertFalse(r[0])
yield from conn.wait_closed()
yield from conn.ensure_closed()
yield from conn.ping()
yield from conn.autocommit(True)
yield from c.execute("""select @@autocommit;""")
r = yield from c.fetchone()
self.assertTrue(r[0])
yield from conn.wait_closed()
yield from conn.ensure_closed()

@run_until_complete
def test_issue_175(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def go():
pool = yield from self.create_pool()
conn = yield from pool.acquire()
self.assertEqual(9, pool.freesize)
yield from conn.wait_closed()
yield from conn.ensure_closed()
pool.release(conn)
self.assertEqual(9, pool.freesize)
self.assertFalse(pool._used)
Expand Down

0 comments on commit 4897b68

Please sign in to comment.