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 f3fb377

Browse filesBrowse files
bramusandrewferlitsch
authored andcommitted
Correctly restore connection if MySQL server has gone away (GoogleCloudPlatform#2421)
1 parent 900900b commit f3fb377
Copy full SHA for f3fb377

File tree

Expand file treeCollapse file tree

1 file changed

+2
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+2
-4
lines changed

‎functions/sql/mysql_sample.py

Copy file name to clipboardExpand all lines: functions/sql/mysql_sample.py
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,9 @@ def __get_cursor():
4646
PyMySQL does NOT automatically reconnect,
4747
so we must reconnect explicitly using ping()
4848
"""
49-
try:
50-
return mysql_conn.cursor()
51-
except OperationalError:
49+
if not mysql_conn.open:
5250
mysql_conn.ping(reconnect=True)
53-
return mysql_conn.cursor()
51+
return mysql_conn.cursor()
5452

5553

5654
def mysql_demo(request):

0 commit comments

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