Sitic has submitted this change and it was merged. Change subject: Only use one redis channel per client ......................................................................
Only use one redis channel per client Change-Id: Ib5a69ab6a74e809ecf00bd475e04ae3a57c45552 --- M backend/server/__init__.py 1 file changed, 6 insertions(+), 15 deletions(-) Approvals: Sitic: Verified; Looks good to me, approved diff --git a/backend/server/__init__.py b/backend/server/__init__.py index 363fe9f..dfe9245 100644 --- a/backend/server/__init__.py +++ b/backend/server/__init__.py @@ -39,34 +39,25 @@ class SockConnection(SockJSConnection): def on_open(self, info): - self.channels = [] + self.channel = str(uuid4()) + subscriber.subscribe(self.channel, self) def on_close(self): - for channel in self.channels: - subscriber.unsubscribe(channel, self) + subscriber.unsubscribe(self.channel, self) def on_message(self, message): data = json.loads(message) + data['redis_channel'] = self.channel if data['action'] == 'watchlist': - redis_channel = str(uuid4()) - self.channels.append(redis_channel) - - logging.info('New redis channel ' + redis_channel) - subscriber.subscribe(redis_channel, self) - - data['redis_channel'] = redis_channel celery_app.send_task('backend.celery.tasks.initial_task', kwargs=data, expires=60) elif data['action'] == 'notifications_mark_read': celery_app.send_task('backend.celery.tasks.notifications_mark_read', kwargs=data, expires=60) elif data['action'] == 'diff': - redis_channel = str(uuid4()) - self.channels.append(redis_channel) - subscriber.subscribe(redis_channel, self) - - data['redis_channel'] = redis_channel celery_app.send_task('backend.celery.tasks.get_diff', kwargs=data) + else: + logging.error('Unrecognized action for message: ' + str(data)) class NoChacheStaticFileHandler(StaticFileHandler): -- To view, visit https://gerrit.wikimedia.org/r/226082 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib5a69ab6a74e809ecf00bd475e04ae3a57c45552 Gerrit-PatchSet: 1 Gerrit-Project: labs/tools/crosswatch Gerrit-Branch: master Gerrit-Owner: Sitic <jan.leb...@online.de> Gerrit-Reviewer: Sitic <jan.leb...@online.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits