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

Bugfix/fix notice word #869

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lyrebird/db/database_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
class LyrebirdDatabaseServer(ThreadServer):
def __init__(self, path=None):
self.database_uri = None
self.error_log = []
self.error_log_threshold = application.config.get('event.db_connection_recover_threshold', 0)
super().__init__()

if not path or path.isspace():
Expand Down Expand Up @@ -162,12 +164,19 @@ def run(self):
session.add(event)
session.commit()
context.emit('db_action', 'add event log')
except OperationalError:
except OperationalError as e:
logger.error(f'Save event failed. {traceback.format_exc()}')
logger.warning(f'DB would be reset: {self.database_uri}')
self.reset()
self.error_log.append(e)
if len(self.error_log) > self.error_log_threshold:
logger.warning(f'DB would be reset: {self.database_uri}')
self.error_log = []
self.reset()
session = self._scoped_session()
else:
session.rollback()
except Exception:
logger.error(f'Save event failed. {traceback.format_exc()}')
session.rollback()

def stop(self):
super().stop()
Expand Down
2 changes: 1 addition & 1 deletion lyrebird/mock/extra_mock_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ async def send_request(context: LyrebirdProxyContext, target_url):
async for data in _resp.content.iter_any():
await resp.write(data)
await resp.write_eof()
logger.info(f'Stream Request finished: {proxy_resp_status} {context.origin_url}')
logger.info(f'Stream Response finished: {proxy_resp_status} {context.origin_url}')
else:
proxy_resp_data = await _resp.read()
response_headers = await make_response_header(proxy_resp_headers, context, proxy_resp_data)
Expand Down
Loading