@@ -121,7 +121,7 @@ static int _mysql_server_init_done = 0;
121
121
/* According to https://dev.mysql.com/doc/refman/5.1/en/mysql-options.html
122
122
The MYSQL_OPT_READ_TIMEOUT apear in the version 5.1.12 */
123
123
#if MYSQL_VERSION_ID > 50112
124
- #define HAVE_MYSQL_OPT_READ_TIMEOUT 1
124
+ #define HAVE_MYSQL_OPT_TIMEOUTS 1
125
125
#endif
126
126
127
127
PyObject *
@@ -566,13 +566,15 @@ _mysql_ConnectionObject_Initialize(
566
566
"read_default_file" , "read_default_group" ,
567
567
"client_flag" , "ssl" ,
568
568
"local_infile" ,
569
- #ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
569
+ #ifdef HAVE_MYSQL_OPT_TIMEOUTS
570
570
"read_timeout" ,
571
+ "write_timeout" ,
571
572
#endif
572
573
NULL } ;
573
574
int connect_timeout = 0 ;
574
- #ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
575
+ #ifdef HAVE_MYSQL_OPT_TIMEOUTS
575
576
int read_timeout = 0 ;
577
+ int write_timeout = 0 ;
576
578
#endif
577
579
int compress = -1 , named_pipe = -1 , local_infile = -1 ;
578
580
char * init_command = NULL ,
@@ -584,8 +586,8 @@ _mysql_ConnectionObject_Initialize(
584
586
check_server_init (-1 );
585
587
586
588
if (!PyArg_ParseTupleAndKeywords (args , kwargs ,
587
- #ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
588
- "|ssssisOiiisssiOii :connect" ,
589
+ #ifdef HAVE_MYSQL_OPT_TIMEOUTS
590
+ "|ssssisOiiisssiOiii :connect" ,
589
591
#else
590
592
"|ssssisOiiisssiOi:connect" ,
591
593
#endif
@@ -598,8 +600,9 @@ _mysql_ConnectionObject_Initialize(
598
600
& read_default_group ,
599
601
& client_flag , & ssl ,
600
602
& local_infile
601
- #ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
603
+ #ifdef HAVE_MYSQL_OPT_TIMEOUTS
602
604
, & read_timeout
605
+ , & write_timeout
603
606
#endif
604
607
))
605
608
return -1 ;
@@ -636,12 +639,17 @@ _mysql_ConnectionObject_Initialize(
636
639
mysql_options (& (self -> connection ), MYSQL_OPT_CONNECT_TIMEOUT ,
637
640
(char * )& timeout );
638
641
}
639
- #ifdef HAVE_MYSQL_OPT_READ_TIMEOUT
642
+ #ifdef HAVE_MYSQL_OPT_TIMEOUTS
640
643
if (read_timeout ) {
641
644
unsigned int timeout = read_timeout ;
642
645
mysql_options (& (self -> connection ), MYSQL_OPT_READ_TIMEOUT ,
643
646
(char * )& timeout );
644
647
}
648
+ if (write_timeout ) {
649
+ unsigned int timeout = write_timeout ;
650
+ mysql_options (& (self -> connection ), MYSQL_OPT_WRITE_TIMEOUT ,
651
+ (char * )& timeout );
652
+ }
645
653
#endif
646
654
if (compress != -1 ) {
647
655
mysql_options (& (self -> connection ), MYSQL_OPT_COMPRESS , 0 );
0 commit comments