Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore reclose db error by pymysql.err.Error #31

Closed
wants to merge 1 commit into from

Conversation

iepngs
Copy link

@iepngs iepngs commented Apr 20, 2018

when it used on flask with socketio, will be trigger teardown_request event as muilt times by the client long-polling, there were some trace log:

Traceback (most recent call last):
File "D:\Tools\Python363\lib\site-packages\eventlet\wsgi.py", line 539, in handle_one_response
result = self.application(self.environ, start_response)
File "D:\Tools\Python363\lib\site-packages\flask\app.py", line 1997, in call
return self.wsgi_app(environ, start_response)
File "D:\Tools\Python363\lib\site-packages\engineio\middleware.py", line 49, in call
return self.wsgi_app(environ, start_response)
File "D:\Tools\Python363\lib\site-packages\flask\app.py", line 1993, in wsgi_app
ctx.auto_pop(error)
File "D:\Tools\Python363\lib\site-packages\flask\ctx.py", line 387, in auto_pop
self.pop(exc)
File "D:\Tools\Python363\lib\site-packages\flask\ctx.py", line 353, in pop
self.app.do_teardown_request(exc)
File "D:\Tools\Python363\lib\site-packages\flask\app.py", line 1879, in do_teardown_request
func(exc)
File "D:\Tools\Python363\lib\site-packages\flaskext\mysql.py", line 59, in teardown_request
ctx.mysql_db.close()
File "D:\Tools\Python363\lib\site-packages\pymysql\connections.py", line 728, in close
raise err.Error("Already closed")
pymysql.err.Error: Already closed

when it used on flask with socketio, will be trigger teardown_request event as muilt times by the client long-polling, there were some trace log:

Traceback (most recent call last):
  File "D:\Tools\Python363\lib\site-packages\eventlet\wsgi.py", line 539, in handle_one_response
    result = self.application(self.environ, start_response)
  File "D:\Tools\Python363\lib\site-packages\flask\app.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "D:\Tools\Python363\lib\site-packages\engineio\middleware.py", line 49, in __call__
    return self.wsgi_app(environ, start_response)
  File "D:\Tools\Python363\lib\site-packages\flask\app.py", line 1993, in wsgi_app
    ctx.auto_pop(error)
  File "D:\Tools\Python363\lib\site-packages\flask\ctx.py", line 387, in auto_pop
    self.pop(exc)
  File "D:\Tools\Python363\lib\site-packages\flask\ctx.py", line 353, in pop
    self.app.do_teardown_request(exc)
  File "D:\Tools\Python363\lib\site-packages\flask\app.py", line 1879, in do_teardown_request
    func(exc)
  File "D:\Tools\Python363\lib\site-packages\flaskext\mysql.py", line 59, in teardown_request
    ctx.mysql_db.close()
  File "D:\Tools\Python363\lib\site-packages\pymysql\connections.py", line 728, in close
    raise err.Error("Already closed")
pymysql.err.Error: Already closed
@gobraves
Copy link

gobraves commented May 23, 2018

line 60 is wrong
try:
...
except Exception as e:
...

@iepngs
Copy link
Author

iepngs commented May 24, 2018

runing on python2?

@gobraves
Copy link

you wrote wrong at line 60 in the code you have committed, it is except Exception instead of catch Exception. catch Exception is not used in python2 or python3

@cyberdelia cyberdelia closed this Jan 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants