diff --git a/doc/src/connection.rst b/doc/src/connection.rst index ec4a4ee2..2dbea6cb 100644 --- a/doc/src/connection.rst +++ b/doc/src/connection.rst @@ -322,9 +322,9 @@ The ``connection`` class .. seealso:: :ref:`Asynchronous 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() diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c index 432078fb..919e7e4d 100644 --- a/psycopg/connection_type.c +++ b/psycopg/connection_type.c @@ -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."}, diff --git a/tests/test_async.py b/tests/test_async.py index e1b50cbf..fe00555e 100755 --- a/tests/test_async.py +++ b/tests/test_async.py @@ -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):