class IdempotentContextedServer(zerorpc.Server): def _async_task(self, initial_event): channel_id = initial_event.header.get(u'message_id') logger.info("executing _async_task for %s", channel_id) if channel_id in self._multiplexer.active_channels: logger.info('A request with same channel_id %s is already in progress. Ignoring this one', channel_id) return
return super(IdempotentContextedServer, self)._async_task(initial_event)
--
You received this message because you are subscribed to the Google Groups "zerorpc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zerorpc+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/zerorpc/cb25231d-e8bd-4722-afe3-92fc735c465a%40googlegroups.com.
class UniqueContextedServer(zerorpc.Server): def __init__(self, *a, **kw): super(IdempotentContextedServer, self).__init__(*a, **kw) self.active_contexts = set([])
def _async_task(self, initial_event): context_id = initial_event.header.get(u'context_id') if context_id is not None and context_id in self.active_contexts: return
self.active_contexts.add(context_id) try: return super(IdempotentContextedServer, self)._async_task(initial_event) finally: self.active_contexts.discard(context_id)