mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-03-03 15:45:46 +03:00
Connection method 'executing()' renamed to 'isexecuting()'.
This commit is contained in:
parent
7ee09353ec
commit
6fecc36b7f
|
@ -334,7 +334,7 @@ client and available using the regular cursor methods:
|
||||||
>>> acurs.fetchone()[0]
|
>>> acurs.fetchone()[0]
|
||||||
42
|
42
|
||||||
|
|
||||||
When an asynchronous query is being executed, `connection.executing()` returns
|
When an asynchronous query is being executed, `connection.isexecuting()` returns
|
||||||
`True`. Two cursors can't execute concurrent queries on the same asynchronous
|
`True`. Two cursors can't execute concurrent queries on the same asynchronous
|
||||||
connection.
|
connection.
|
||||||
|
|
||||||
|
|
|
@ -347,7 +347,7 @@ The ``connection`` class
|
||||||
its status during asynchronous communication.
|
its status during asynchronous communication.
|
||||||
|
|
||||||
|
|
||||||
.. method:: executing()
|
.. method:: isexecuting()
|
||||||
|
|
||||||
Return `True` if the connection is executing an asynchronous operation.
|
Return `True` if the connection is executing an asynchronous operation.
|
||||||
|
|
||||||
|
|
|
@ -547,14 +547,14 @@ psyco_conn_fileno(connectionObject *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* extension: executing - check for asynchronous operations */
|
/* extension: isexecuting - check for asynchronous operations */
|
||||||
|
|
||||||
#define psyco_conn_executing_doc \
|
#define psyco_conn_isexecuting_doc \
|
||||||
"executing() -> bool -- Return True if the connection is " \
|
"isexecuting() -> bool -- Return True if the connection is " \
|
||||||
"executing an asynchronous operation."
|
"executing an asynchronous operation."
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
psyco_conn_executing(connectionObject *self)
|
psyco_conn_isexecuting(connectionObject *self)
|
||||||
{
|
{
|
||||||
/* synchronous connections will always return False */
|
/* synchronous connections will always return False */
|
||||||
if (self->async == 0) {
|
if (self->async == 0) {
|
||||||
|
@ -612,8 +612,8 @@ static struct PyMethodDef connectionObject_methods[] = {
|
||||||
METH_NOARGS, psyco_conn_lobject_doc},
|
METH_NOARGS, psyco_conn_lobject_doc},
|
||||||
{"fileno", (PyCFunction)psyco_conn_fileno,
|
{"fileno", (PyCFunction)psyco_conn_fileno,
|
||||||
METH_NOARGS, psyco_conn_fileno_doc},
|
METH_NOARGS, psyco_conn_fileno_doc},
|
||||||
{"executing", (PyCFunction)psyco_conn_executing,
|
{"isexecuting", (PyCFunction)psyco_conn_isexecuting,
|
||||||
METH_NOARGS, psyco_conn_executing_doc},
|
METH_NOARGS, psyco_conn_isexecuting_doc},
|
||||||
#endif
|
#endif
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
|
@ -80,13 +80,13 @@ class AsyncTests(unittest.TestCase):
|
||||||
|
|
||||||
def test_async_select(self):
|
def test_async_select(self):
|
||||||
cur = self.conn.cursor()
|
cur = self.conn.cursor()
|
||||||
self.assertFalse(self.conn.executing())
|
self.assertFalse(self.conn.isexecuting())
|
||||||
cur.execute("select 'a'")
|
cur.execute("select 'a'")
|
||||||
self.assertTrue(self.conn.executing())
|
self.assertTrue(self.conn.isexecuting())
|
||||||
|
|
||||||
self.wait(cur)
|
self.wait(cur)
|
||||||
|
|
||||||
self.assertFalse(self.conn.executing())
|
self.assertFalse(self.conn.isexecuting())
|
||||||
self.assertEquals(cur.fetchone()[0], "a")
|
self.assertEquals(cur.fetchone()[0], "a")
|
||||||
|
|
||||||
def test_async_callproc(self):
|
def test_async_callproc(self):
|
||||||
|
@ -96,10 +96,10 @@ class AsyncTests(unittest.TestCase):
|
||||||
except psycopg2.ProgrammingError:
|
except psycopg2.ProgrammingError:
|
||||||
# PG <8.1 did not have pg_sleep
|
# PG <8.1 did not have pg_sleep
|
||||||
return
|
return
|
||||||
self.assertTrue(self.conn.executing())
|
self.assertTrue(self.conn.isexecuting())
|
||||||
|
|
||||||
self.wait(cur)
|
self.wait(cur)
|
||||||
self.assertFalse(self.conn.executing())
|
self.assertFalse(self.conn.isexecuting())
|
||||||
self.assertEquals(cur.fetchall()[0][0], '')
|
self.assertEquals(cur.fetchall()[0][0], '')
|
||||||
|
|
||||||
def test_async_after_async(self):
|
def test_async_after_async(self):
|
||||||
|
@ -158,7 +158,7 @@ class AsyncTests(unittest.TestCase):
|
||||||
|
|
||||||
# a commit should not work in asynchronous mode
|
# a commit should not work in asynchronous mode
|
||||||
self.assertRaises(psycopg2.ProgrammingError, self.conn.commit)
|
self.assertRaises(psycopg2.ProgrammingError, self.conn.commit)
|
||||||
self.assertTrue(self.conn.executing())
|
self.assertTrue(self.conn.isexecuting())
|
||||||
|
|
||||||
# but a manual commit should
|
# but a manual commit should
|
||||||
self.wait(cur)
|
self.wait(cur)
|
||||||
|
@ -180,12 +180,12 @@ class AsyncTests(unittest.TestCase):
|
||||||
cur = self.conn.cursor()
|
cur = self.conn.cursor()
|
||||||
|
|
||||||
cur.execute("select 'c'")
|
cur.execute("select 'c'")
|
||||||
self.assertTrue(self.conn.executing())
|
self.assertTrue(self.conn.isexecuting())
|
||||||
|
|
||||||
# getting transaction status works
|
# getting transaction status works
|
||||||
self.assertEquals(self.conn.get_transaction_status(),
|
self.assertEquals(self.conn.get_transaction_status(),
|
||||||
extensions.TRANSACTION_STATUS_ACTIVE)
|
extensions.TRANSACTION_STATUS_ACTIVE)
|
||||||
self.assertTrue(self.conn.executing())
|
self.assertTrue(self.conn.isexecuting())
|
||||||
|
|
||||||
# setting connection encoding should fail
|
# setting connection encoding should fail
|
||||||
self.assertRaises(psycopg2.ProgrammingError,
|
self.assertRaises(psycopg2.ProgrammingError,
|
||||||
|
@ -198,7 +198,7 @@ class AsyncTests(unittest.TestCase):
|
||||||
def test_reset_while_async(self):
|
def test_reset_while_async(self):
|
||||||
cur = self.conn.cursor()
|
cur = self.conn.cursor()
|
||||||
cur.execute("select 'c'")
|
cur.execute("select 'c'")
|
||||||
self.assertTrue(self.conn.executing())
|
self.assertTrue(self.conn.isexecuting())
|
||||||
|
|
||||||
# a reset should fail
|
# a reset should fail
|
||||||
self.assertRaises(psycopg2.ProgrammingError, self.conn.reset)
|
self.assertRaises(psycopg2.ProgrammingError, self.conn.reset)
|
||||||
|
@ -218,7 +218,7 @@ class AsyncTests(unittest.TestCase):
|
||||||
# but after it's done it should work
|
# but after it's done it should work
|
||||||
self.wait(cur)
|
self.wait(cur)
|
||||||
self.assertEquals(list(cur), [(1, ), (2, ), (3, )])
|
self.assertEquals(list(cur), [(1, ), (2, ), (3, )])
|
||||||
self.assertFalse(self.conn.executing())
|
self.assertFalse(self.conn.isexecuting())
|
||||||
|
|
||||||
def test_copy_while_async(self):
|
def test_copy_while_async(self):
|
||||||
cur = self.conn.cursor()
|
cur = self.conn.cursor()
|
||||||
|
@ -248,7 +248,7 @@ class AsyncTests(unittest.TestCase):
|
||||||
|
|
||||||
# scroll should fail if a query is underway
|
# scroll should fail if a query is underway
|
||||||
self.assertRaises(psycopg2.ProgrammingError, cur.scroll, 1)
|
self.assertRaises(psycopg2.ProgrammingError, cur.scroll, 1)
|
||||||
self.assertTrue(self.conn.executing())
|
self.assertTrue(self.conn.isexecuting())
|
||||||
|
|
||||||
# but after it's done it should work
|
# but after it's done it should work
|
||||||
self.wait(cur)
|
self.wait(cur)
|
||||||
|
@ -350,7 +350,7 @@ class AsyncTests(unittest.TestCase):
|
||||||
cur1.execute("select 1")
|
cur1.execute("select 1")
|
||||||
|
|
||||||
self.wait(cur1)
|
self.wait(cur1)
|
||||||
self.assertFalse(self.conn.executing())
|
self.assertFalse(self.conn.isexecuting())
|
||||||
# fetching from a cursor with no results is an error
|
# fetching from a cursor with no results is an error
|
||||||
self.assertRaises(psycopg2.ProgrammingError, cur2.fetchone)
|
self.assertRaises(psycopg2.ProgrammingError, cur2.fetchone)
|
||||||
# fetching from the correct cursor works
|
# fetching from the correct cursor works
|
||||||
|
|
Loading…
Reference in New Issue
Block a user