mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
Connection method 'issync()' changed into the attribute 'async'.
This commit is contained in:
parent
7cf52da969
commit
7ee09353ec
|
@ -322,9 +322,9 @@ The ``connection`` class
|
|||
.. seealso:: :ref:`Asynchronous support <async-support>`.
|
||||
|
||||
|
||||
.. method:: issync()
|
||||
.. attribute:: async
|
||||
|
||||
Return `True` if the connection is synchronous, `False` if asynchronous.
|
||||
Read only attribute: 1 if the connection is asynchronous, 0 otherwse.
|
||||
|
||||
|
||||
.. method:: poll()
|
||||
|
|
|
@ -547,25 +547,6 @@ psyco_conn_fileno(connectionObject *self)
|
|||
}
|
||||
|
||||
|
||||
/* extension: issync - tell if the connection is synchronous */
|
||||
|
||||
#define psyco_conn_issync_doc \
|
||||
"issync() -> bool -- Return True if the connection is synchronous."
|
||||
|
||||
static PyObject *
|
||||
psyco_conn_issync(connectionObject *self)
|
||||
{
|
||||
if (self->async) {
|
||||
Py_INCREF(Py_False);
|
||||
return Py_False;
|
||||
}
|
||||
else {
|
||||
Py_INCREF(Py_True);
|
||||
return Py_True;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* extension: executing - check for asynchronous operations */
|
||||
|
||||
#define psyco_conn_executing_doc \
|
||||
|
@ -631,8 +612,6 @@ static struct PyMethodDef connectionObject_methods[] = {
|
|||
METH_NOARGS, psyco_conn_lobject_doc},
|
||||
{"fileno", (PyCFunction)psyco_conn_fileno,
|
||||
METH_NOARGS, psyco_conn_fileno_doc},
|
||||
{"issync", (PyCFunction)psyco_conn_issync,
|
||||
METH_NOARGS, psyco_conn_issync_doc},
|
||||
{"executing", (PyCFunction)psyco_conn_executing,
|
||||
METH_NOARGS, psyco_conn_executing_doc},
|
||||
#endif
|
||||
|
@ -654,6 +633,8 @@ static struct PyMemberDef connectionObject_members[] = {
|
|||
{"notifies", T_OBJECT, offsetof(connectionObject, notifies), RO},
|
||||
{"dsn", T_STRING, offsetof(connectionObject, dsn), RO,
|
||||
"The current connection string."},
|
||||
{"async", T_LONG, offsetof(connectionObject, async), RO,
|
||||
"True if the connection is asynchronous."},
|
||||
{"status", T_INT,
|
||||
offsetof(connectionObject, status), RO,
|
||||
"The current transaction status."},
|
||||
|
|
|
@ -68,8 +68,8 @@ class AsyncTests(unittest.TestCase):
|
|||
cur = self.conn.cursor()
|
||||
sync_cur = self.sync_conn.cursor()
|
||||
|
||||
self.assertEquals(self.conn.issync(), False)
|
||||
self.assertEquals(self.sync_conn.issync(), True)
|
||||
self.assert_(self.conn.async)
|
||||
self.assert_(not self.sync_conn.async)
|
||||
|
||||
# the async connection should be in isolevel 0
|
||||
self.assertEquals(self.conn.isolation_level, 0)
|
||||
|
@ -297,7 +297,7 @@ class AsyncTests(unittest.TestCase):
|
|||
|
||||
conn = psycopg2.connect(tests.dsn, connection_factory=MyConn, async=True)
|
||||
self.assert_(isinstance(conn, MyConn))
|
||||
self.assert_(not conn.issync())
|
||||
self.assert_(conn.async)
|
||||
conn.close()
|
||||
|
||||
def test_flush_on_write(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user