Open GoogleCodeExporter opened 8 years ago
Forgot to mention, the documentation could be incorrect since the Connection
page doesn't have any information on the timeout keyword. I may be using it
incorrectly or using the wrong keyword argument, but the source shows the
keyword being 'timeout'.
Original comment by dkleeham...@gmail.com
on 12 Jun 2012 at 6:52
Any update on that?
I am setting timeout=10 as above and some connections timeout after 2 minutes.
Connecting from SuSE Linux using FreeTDS driver version 0.82
SQLServer 2008R2
Original comment by shlomo.a...@gmail.com
on 16 Feb 2013 at 3:00
There is Connection_settimeout function that set SQL_ATTR_CONNECTION_TIMEOUT on
PyObject but it is not possible to use it before Connect as PyObject does not
exist. So quick solution is simply set timeout directly in Connect function and
update timeout attribute of PyObject.
--- connection.cpp.orig 2013-09-07 10:12:48.000000000 +0400
+++ connection.cpp 2013-09-07 10:51:16.000000000 +0400
@@ -72,6 +72,12 @@
if (timeout > 0)
{
Py_BEGIN_ALLOW_THREADS
+ ret = SQLSetConnectAttr(hdbc, SQL_ATTR_CONNECTION_TIMEOUT,
(SQLPOINTER)timeout, SQL_IS_UINTEGER);
+ Py_END_ALLOW_THREADS
+ if (!SQL_SUCCEEDED(ret))
+
RaiseErrorFromHandle("SQLSetConnectAttr(SQL_ATTR_CONNECTION_TIMEOUT)", hdbc,
SQL_NULL_HANDLE);
+
+ Py_BEGIN_ALLOW_THREADS
ret = SQLSetConnectAttr(hdbc, SQL_ATTR_LOGIN_TIMEOUT, (SQLPOINTER)timeout, SQL_IS_UINTEGER);
Py_END_ALLOW_THREADS
if (!SQL_SUCCEEDED(ret))
@@ -197,7 +203,7 @@
cnxn->hdbc = hdbc;
cnxn->nAutoCommit = fAutoCommit ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF;
cnxn->searchescape = 0;
- cnxn->timeout = 0;
+ cnxn->timeout = timeout;
cnxn->unicode_results = fUnicodeResults;
cnxn->conv_count = 0;
cnxn->conv_types = 0;
Indeed more elegant solution is separate timeouts:
SQL_ATTR_CONNECTION_TIMEOUT
SQL_ATTR_LOGIN_TIMEOUT
SQL_ATTR_QUERY_TIMEOUT
Original comment by aleksey....@gmail.com
on 7 Sep 2013 at 6:53
I tried this patch in connection.cpp but did not work form me. timeout still is
unpredictable.
Original comment by singhai....@gmail.com
on 7 Mar 2014 at 12:04
Original issue reported on code.google.com by
dkleeham...@gmail.com
on 12 Jun 2012 at 6:51