Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d236bb7

Browse filesBrowse files
committed
Merge pull request PyMySQL#26 from chipturner/master
Extend read_timeout support to also include write_timeouts
2 parents 002bbb8 + 7e73533 commit d236bb7
Copy full SHA for d236bb7

File tree

Expand file treeCollapse file tree

1 file changed

+15
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-7
lines changed

‎_mysql.c

Copy file name to clipboardExpand all lines: _mysql.c
+15-7Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static int _mysql_server_init_done = 0;
121121
/* According to https://dev.mysql.com/doc/refman/5.1/en/mysql-options.html
122122
The MYSQL_OPT_READ_TIMEOUT apear in the version 5.1.12 */
123123
#if MYSQL_VERSION_ID > 50112
124-
#define HAVE_MYSQL_OPT_READ_TIMEOUT 1
124+
#define HAVE_MYSQL_OPT_TIMEOUTS 1
125125
#endif
126126

127127
PyObject *
@@ -566,13 +566,15 @@ _mysql_ConnectionObject_Initialize(
566566
"read_default_file", "read_default_group",
567567
"client_flag", "ssl",
568568
"local_infile",
569-
#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
569+
#ifdef HAVE_MYSQL_OPT_TIMEOUTS
570570
"read_timeout",
571+
"write_timeout",
571572
#endif
572573
NULL } ;
573574
int connect_timeout = 0;
574-
#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
575+
#ifdef HAVE_MYSQL_OPT_TIMEOUTS
575576
int read_timeout = 0;
577+
int write_timeout = 0;
576578
#endif
577579
int compress = -1, named_pipe = -1, local_infile = -1;
578580
char *init_command=NULL,
@@ -584,8 +586,8 @@ _mysql_ConnectionObject_Initialize(
584586
check_server_init(-1);
585587

586588
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
587-
#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
588-
"|ssssisOiiisssiOii:connect",
589+
#ifdef HAVE_MYSQL_OPT_TIMEOUTS
590+
"|ssssisOiiisssiOiii:connect",
589591
#else
590592
"|ssssisOiiisssiOi:connect",
591593
#endif
@@ -598,8 +600,9 @@ _mysql_ConnectionObject_Initialize(
598600
&read_default_group,
599601
&client_flag, &ssl,
600602
&local_infile
601-
#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
603+
#ifdef HAVE_MYSQL_OPT_TIMEOUTS
602604
, &read_timeout
605+
, &write_timeout
603606
#endif
604607
))
605608
return -1;
@@ -636,12 +639,17 @@ _mysql_ConnectionObject_Initialize(
636639
mysql_options(&(self->connection), MYSQL_OPT_CONNECT_TIMEOUT,
637640
(char *)&timeout);
638641
}
639-
#ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
642+
#ifdef HAVE_MYSQL_OPT_TIMEOUTS
640643
if (read_timeout) {
641644
unsigned int timeout = read_timeout;
642645
mysql_options(&(self->connection), MYSQL_OPT_READ_TIMEOUT,
643646
(char *)&timeout);
644647
}
648+
if (write_timeout) {
649+
unsigned int timeout = write_timeout;
650+
mysql_options(&(self->connection), MYSQL_OPT_WRITE_TIMEOUT,
651+
(char *)&timeout);
652+
}
645653
#endif
646654
if (compress != -1) {
647655
mysql_options(&(self->connection), MYSQL_OPT_COMPRESS, 0);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.