Skip to content

Commit

Permalink
Change default connect_timeout to 10.
Browse files Browse the repository at this point in the history
  • Loading branch information
methane committed Jan 12, 2017
1 parent 0e19ed3 commit e22a14a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pymysql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def __init__(self, host=None, user=None, password="",
charset='', sql_mode=None,
read_default_file=None, conv=None, use_unicode=None,
client_flag=0, cursorclass=Cursor, init_command=None,
connect_timeout=None, ssl=None, read_default_group=None,
connect_timeout=10, ssl=None, read_default_group=None,
compress=None, named_pipe=None, no_delay=None,
autocommit=False, db=None, passwd=None, local_infile=False,
max_allowed_packet=16*1024*1024, defer_connect=False,
Expand Down Expand Up @@ -564,6 +564,7 @@ def __init__(self, host=None, user=None, password="",
cursorclass: Custom cursor class to use.
init_command: Initial SQL statement to run when connection is established.
connect_timeout: Timeout before throwing an exception when connecting.
(default: 10, min: 1, max: 31536000)
ssl:
A dict of arguments similar to mysql_ssl_set()'s parameters.
For now the capath and cipher arguments are not supported.
Expand Down Expand Up @@ -646,6 +647,9 @@ def _config(key, arg):
self.db = database
self.unix_socket = unix_socket
self.bind_address = bind_address
if not (0 < connect_timeout <= 31536000):
raise ValueError("connect_timeout should be >0 and <=31536000")
self.connect_timeout = connect_timeout or None
if read_timeout is not None and read_timeout <= 0:
raise ValueError("read_timeout should be >= 0")
self._read_timeout = read_timeout
Expand All @@ -670,7 +674,6 @@ def _config(key, arg):
self.client_flag = client_flag

self.cursorclass = cursorclass
self.connect_timeout = connect_timeout or None

self._result = None
self._affected_rows = 0
Expand Down

0 comments on commit e22a14a

Please sign in to comment.