mirror of https://github.com/zulip/zulip.git
ruff: Fix B012 return inside finally blocks.
return inside finally blocks causes exceptions to be silenced. Although these blocks follow blanket ‘except Exception’ handlers, they do not seem to have a goal of silencing BaseException and exceptions thrown by the exception handler, so rewrite them to avoid it. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
c4e5ddd67f
commit
1735b8863e
|
@ -208,7 +208,7 @@ class ClientDescriptor:
|
||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
self.disconnect_handler()
|
self.disconnect_handler()
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def accepts_event(self, event: Mapping[str, Any]) -> bool:
|
def accepts_event(self, event: Mapping[str, Any]) -> bool:
|
||||||
|
|
|
@ -339,16 +339,16 @@ class QueueProcessingWorker(ABC):
|
||||||
# especially since the queue might go idle until new events come in.
|
# especially since the queue might go idle until new events come in.
|
||||||
self.update_statistics()
|
self.update_statistics()
|
||||||
self.idle = True
|
self.idle = True
|
||||||
return
|
else:
|
||||||
|
self.consume_iteration_counter += 1
|
||||||
self.consume_iteration_counter += 1
|
if (
|
||||||
if (
|
self.consume_iteration_counter
|
||||||
self.consume_iteration_counter >= self.CONSUME_ITERATIONS_BEFORE_UPDATE_STATS_NUM
|
>= self.CONSUME_ITERATIONS_BEFORE_UPDATE_STATS_NUM
|
||||||
or time.time() - self.last_statistics_update_time
|
or time.time() - self.last_statistics_update_time
|
||||||
>= self.MAX_SECONDS_BEFORE_UPDATE_STATS
|
>= self.MAX_SECONDS_BEFORE_UPDATE_STATS
|
||||||
):
|
):
|
||||||
self.consume_iteration_counter = 0
|
self.consume_iteration_counter = 0
|
||||||
self.update_statistics()
|
self.update_statistics()
|
||||||
|
|
||||||
def consume_single_event(self, event: Dict[str, Any]) -> None:
|
def consume_single_event(self, event: Dict[str, Any]) -> None:
|
||||||
consume_func = lambda events: self.consume(events[0])
|
consume_func = lambda events: self.consume(events[0])
|
||||||
|
|
Loading…
Reference in New Issue