Демихов Валентин, 611 группа SyncSeq 18429
Шереметьева Анастасия Александровна, 419/2 группа SyncSeq 18485
f1import asynciof1import asyncio
2import random2import random
33
4class Seq:4class Seq:
n5    _instance_count = 0n5    _counter = 0
6    _worker_tasks = []6    _events = []
77
8    def __init__(self, name):8    def __init__(self, name):
9        self.name = name9        self.name = name
n10        self._id = Seq._instance_countn10        self.id = Seq._counter
11        Seq._instance_count += 111        Seq._counter += 1
12        while len(Seq._worker_tasks) <= self._id:12        while len(Seq._events) <= self.id:
13            Seq._worker_tasks.append(asyncio.Event())13            Seq._events.append(asyncio.Event())
1414
15    async def run(self):15    async def run(self):
n16        if self._id > 0:n16        if self.id > 0:
17            await Seq._worker_tasks[self._id - 1].wait()17            await Seq._events[self.id - 1].wait()
18        print(self.name)18        print(self.name)
t19        Seq._worker_tasks[self._id].set()t19        Seq._events[self.id].set()
20        return self.name20        return self.name
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op