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:
|
||||
self.disconnect_handler()
|
||||
return True
|
||||
return True
|
||||
return False
|
||||
|
||||
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.
|
||||
self.update_statistics()
|
||||
self.idle = True
|
||||
return
|
||||
|
||||
self.consume_iteration_counter += 1
|
||||
if (
|
||||
self.consume_iteration_counter >= self.CONSUME_ITERATIONS_BEFORE_UPDATE_STATS_NUM
|
||||
or time.time() - self.last_statistics_update_time
|
||||
>= self.MAX_SECONDS_BEFORE_UPDATE_STATS
|
||||
):
|
||||
self.consume_iteration_counter = 0
|
||||
self.update_statistics()
|
||||
else:
|
||||
self.consume_iteration_counter += 1
|
||||
if (
|
||||
self.consume_iteration_counter
|
||||
>= self.CONSUME_ITERATIONS_BEFORE_UPDATE_STATS_NUM
|
||||
or time.time() - self.last_statistics_update_time
|
||||
>= self.MAX_SECONDS_BEFORE_UPDATE_STATS
|
||||
):
|
||||
self.consume_iteration_counter = 0
|
||||
self.update_statistics()
|
||||
|
||||
def consume_single_event(self, event: Dict[str, Any]) -> None:
|
||||
consume_func = lambda events: self.consume(events[0])
|
||||
|
|
Loading…
Reference in New Issue