@@ -25,7 +25,7 @@ class Connection(object):
25
25
:param key: Private key to access database.
26
26
:param database: Database id to use. uri and database should set at least one.
27
27
:param read_timeout: The timeout for reading from the connection in seconds (default: None - no timeout)
28
- :param write_timeout: The timeout for writing to the connection in seconds (default: None - no timeout)
28
+ #(Not supported now) :param write_timeout: The timeout for writing to the connection in seconds (default: None - no timeout)
29
29
:param read_default_file:
30
30
Specifies my.cnf file to read these parameters from under the [client] section.
31
31
:param cursorclass: Custom cursor class to use.
@@ -42,8 +42,8 @@ class Connection(object):
42
42
43
43
def __init__ (self , dsn = None , host = None , port = 0 , key = None , database = None ,
44
44
https_pem = None , read_default_file = None ,
45
- cursorclass = Cursor , connect_timeout = 10 , read_default_group = None ,
46
- read_timeout = None , write_timeout = None ):
45
+ cursorclass = Cursor , connect_timeout = None , read_default_group = None ,
46
+ read_timeout = None ):
47
47
48
48
self ._resp = None
49
49
@@ -99,15 +99,15 @@ def _config(key, arg):
99
99
else :
100
100
self ._cert = self .key
101
101
102
- if not ( 0 < connect_timeout <= 31536000 ):
103
- raise ValueError ( " connect_timeout should be >0 and <=31536000" )
104
- self . connect_timeout = connect_timeout or None
102
+ self . timeout = None
103
+ if connect_timeout is not None and connect_timeout <= 0 :
104
+ raise ValueError ( " connect_timeout should be >= 0" )
105
105
if read_timeout is not None and read_timeout <= 0 :
106
106
raise ValueError ("read_timeout should be >= 0" )
107
- self . _read_timeout = read_timeout
108
- if write_timeout is not None and write_timeout < = 0 :
109
- raise ValueError ( "write_timeout should be >= 0" )
110
- self ._write_timeout = write_timeout
107
+ #if write_timeout is not None and write_timeout <= 0:
108
+ # raise ValueError(" write_timeout should be > = 0")
109
+ if connect_timeout is not None or read_timeout is not None :
110
+ self .timeout = ( connect_timeout , read_timeout )
111
111
112
112
self .cursorclass = cursorclass
113
113
@@ -227,7 +227,7 @@ def _send(self, uri, data):
227
227
session = requests .Session ()
228
228
session .verify = False
229
229
session .cert = self ._cert
230
- return session .post (uri , data )
230
+ return session .post (uri , data , timeout = self . timeout )
231
231
232
232
def escape (self , obj , mapping = None ):
233
233
"""Escape whatever value you pass to it.
0 commit comments