Commit c967c8b5 authored by Kirill Smelkov's avatar Kirill Smelkov

amari.xlog: Rework "service detach" to be detected and done via defer instead of try/except

We will soon add more levels of trying to this part of the code and
linear defers are easier to follow compared to many levels of try/except
nesting.
parent 749e1659
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2022 Nexedi SA and Contributors. # Copyright (C) 2022-2023 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com> # Kirill Smelkov <kirr@nexedi.com>
# #
# This program is free software: you can Use, Study, Modify and Redistribute # This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your # it under the terms of the GNU General Public License version 3, or (at your
...@@ -180,14 +180,18 @@ class _XLogger: ...@@ -180,14 +180,18 @@ class _XLogger:
"srv_type": conn.srv_type, "srv_type": conn.srv_type,
"srv_version": conn.srv_version} "srv_version": conn.srv_version}
xl.jemit("service attach", srv_info) xl.jemit("service attach", srv_info)
try: def _():
xl._xlog1(conn) try:
except Exception as ex:
d = srv_info.copy()
d['reason'] = str(ex)
xl.jemit("service detach", d)
if not isinstance(ex, amari.ConnError):
raise raise
except Exception as ex:
d = srv_info.copy()
d['reason'] = str(ex)
xl.jemit("service detach", d)
if not isinstance(ex, amari.ConnError):
raise
defer(_)
xl._xlog1(conn)
def _xlog1(xl, conn): def _xlog1(xl, conn):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment