mirror of
https://github.com/ansible/awx.git
synced 2026-01-18 21:21:21 -03:30
cleanup group membership on disconnect
* zcard asgi::group:jobs-status_changed <-- to see a group set that continues to grow. Issue this command in a loop while refreshing the browser page on the jobs list. Before this change the set size would continue to grow as daphne channel names are added to the group. After this change the set size stays stable at the expected, 1.
This commit is contained in:
parent
501568340b
commit
fd068695ef
@ -108,6 +108,7 @@ class BroadcastConsumer(AsyncJsonWebsocketConsumer):
|
||||
async def disconnect(self, code):
|
||||
# TODO: log ip of disconnected client
|
||||
logger.info("Client disconnected")
|
||||
await self.channel_layer.group_discard(settings.BROADCAST_WEBSOCKET_GROUP_NAME, self.channel_name)
|
||||
|
||||
async def internal_message(self, event):
|
||||
await self.send(event['text'])
|
||||
@ -132,6 +133,14 @@ class EventConsumer(AsyncJsonWebsocketConsumer):
|
||||
await self.send_json({"close": True})
|
||||
await self.close()
|
||||
|
||||
async def disconnect(self, code):
|
||||
current_groups = set(self.scope['session'].pop('groups') if 'groups' in self.scope['session'] else [])
|
||||
for group_name in current_groups:
|
||||
await self.channel_layer.group_discard(
|
||||
group_name,
|
||||
self.channel_name,
|
||||
)
|
||||
|
||||
@database_sync_to_async
|
||||
def user_can_see_object_id(self, user_access, oid):
|
||||
# At this point user is a channels.auth.UserLazyObject object
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user