mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 08:26:11 +00:00
event_queue: Rename ClientDescriptor.idle to expired.
This better reflects the situation with these event queues -- they're not idle, they are expired and to be garbage collected.
This commit is contained in:
@@ -180,7 +180,7 @@ class ClientDescriptor:
|
|||||||
def accepts_messages(self) -> bool:
|
def accepts_messages(self) -> bool:
|
||||||
return self.event_types is None or "message" in self.event_types
|
return self.event_types is None or "message" in self.event_types
|
||||||
|
|
||||||
def idle(self, now: float) -> bool:
|
def expired(self, now: float) -> bool:
|
||||||
return (self.current_handler_id is None and
|
return (self.current_handler_id is None and
|
||||||
now - self.last_connection_time >= self.queue_timeout)
|
now - self.last_connection_time >= self.queue_timeout)
|
||||||
|
|
||||||
@@ -398,18 +398,18 @@ def gc_event_queues(port: int) -> None:
|
|||||||
affected_users = set() # type: Set[int]
|
affected_users = set() # type: Set[int]
|
||||||
affected_realms = set() # type: Set[int]
|
affected_realms = set() # type: Set[int]
|
||||||
for (id, client) in clients.items():
|
for (id, client) in clients.items():
|
||||||
if client.idle(start):
|
if client.expired(start):
|
||||||
to_remove.add(id)
|
to_remove.add(id)
|
||||||
affected_users.add(client.user_profile_id)
|
affected_users.add(client.user_profile_id)
|
||||||
affected_realms.add(client.realm_id)
|
affected_realms.add(client.realm_id)
|
||||||
|
|
||||||
# We don't need to call e.g. finish_current_handler on the clients
|
# We don't need to call e.g. finish_current_handler on the clients
|
||||||
# being removed because they are guaranteed to be idle and thus
|
# being removed because they are guaranteed to be idle (because
|
||||||
# not have a current handler.
|
# they are expired) and thus not have a current handler.
|
||||||
do_gc_event_queues(to_remove, affected_users, affected_realms)
|
do_gc_event_queues(to_remove, affected_users, affected_realms)
|
||||||
|
|
||||||
if settings.PRODUCTION:
|
if settings.PRODUCTION:
|
||||||
logging.info(('Tornado %d removed %d idle event queues owned by %d users in %.3fs.' +
|
logging.info(('Tornado %d removed %d expired event queues owned by %d users in %.3fs.' +
|
||||||
' Now %d active queues, %s')
|
' Now %d active queues, %s')
|
||||||
% (port, len(to_remove), len(affected_users), time.time() - start,
|
% (port, len(to_remove), len(affected_users), time.time() - start,
|
||||||
len(clients), handler_stats_string()))
|
len(clients), handler_stats_string()))
|
||||||
|
|||||||
Reference in New Issue
Block a user