服务器 A 是 tornado,去连服务器 B 上的 PostgreSQL 数据库,刚开始没啥问题。
可是时间久了服务器 A 和服务器 B 的数据库连接就断了。
大佬们有遇到过这种情况吗?
附个错误提示:
Traceback (most recent call last):
File "/home/xxx/.local/lib/python3.5/site-packages/peewee.py", line 3756, in execute_sql
cursor = self.get_cursor()
File "/home/xxx/.local/lib/python3.5/site-packages/peewee.py", line 3704, in get_cursor
return self.get_conn().cursor()
psycopg2.InterfaceError: connection already closed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/xxx/.local/lib/python3.5/site-packages/tornado/web.py", line 1488, in _execute
result = self.prepare()
File "/home/xxx/cc_backend/view/__init__.py", line 217, in prepare
if not self.current_user():
File "/home/xxx/cc_backend/view/__init__.py", line 192, in current_user
return User.get_by_key(key)
File "/home/xxx/cc_backend/model/user.py", line 102, in get_by_key
return cls.get(cls.key == key)
File "/home/xxx/.local/lib/python3.5/site-packages/peewee.py", line 4916, in get
return sq.get()
File "/home/xxx/.local/lib/python3.5/site-packages/peewee.py", line 3171, in get
return next(clone.execute())
File "/home/xxx/.local/lib/python3.5/site-packages/peewee.py", line 3223, in execute
self._qr = ResultWrapper(model_class, self._execute(), query_meta)
File "/home/xxx/.local/lib/python3.5/site-packages/peewee.py", line 2902, in _execute
return self.database.execute_sql(sql, params, self.require_commit)
File "/home/xxx/.local/lib/python3.5/site-packages/peewee.py", line 3765, in execute_sql
self.commit()
File "/home/xxx/.local/lib/python3.5/site-packages/peewee.py", line 3588, in __exit__
reraise(new_type, new_type(*exc_args), traceback)
File "/home/xxx/.local/lib/python3.5/site-packages/peewee.py", line 135, in reraise
raise value.with_traceback(tb)
File "/home/xxx/.local/lib/python3.5/site-packages/peewee.py", line 3756, in execute_sql
cursor = self.get_cursor()
File "/home/xxx/.local/lib/python3.5/site-packages/peewee.py", line 3704, in get_cursor
return self.get_conn().cursor()
peewee.InterfaceError: connection already closed