Nikita_luk TwoWay 10721
Aleksey TwoWay 10546
f1import asynciof1import asyncio
22
3class Portal(asyncio.Barrier):3class Portal(asyncio.Barrier):
44
5    def __init__(self, parties):5    def __init__(self, parties):
6        super().__init__(parties)6        super().__init__(parties)
7        self.topic = None7        self.topic = None
8        self._proposed_topic = None8        self._proposed_topic = None
9        self._out_barrier = asyncio.Barrier(parties)9        self._out_barrier = asyncio.Barrier(parties)
1010
11    async def wait(self, topic=None):11    async def wait(self, topic=None):
12        if topic is not None:12        if topic is not None:
13            self._proposed_topic = topic13            self._proposed_topic = topic
n14        index = await super().wait()n14        idx = await super().wait()
15        if index == 0:15        if idx == 0:
16            self.topic = self._proposed_topic16            self.topic = self._proposed_topic
17        await self._out_barrier.wait()17        await self._out_barrier.wait()
t18        return indext18        return idx
1919
20    async def reset(self):20    async def reset(self):
21        self.topic = None21        self.topic = None
22        self._proposed_topic = None22        self._proposed_topic = None
23        await super().reset()23        await super().reset()
24        await self._out_barrier.reset()24        await self._out_barrier.reset()
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op