Closed smallevilbeast closed 1 year ago
example:
import pyee
import asyncio
from asyncio.locks import Lock
class Demo(pyee.AsyncIOEventEmitter):
def __init__(self):
super().__init__()
self._lock = Lock()
async def get_seq(self):
async with self._lock:
return 1
async def send(self):
seq = await self.get_seq()
self.emit('event_test')
class LockTest(pyee.AsyncIOEventEmitter):
def __init__(self):
super().__init__()
self._demo = Demo()
self._demo.on('event_test', self._on_event_test)
async def _on_event_test(self):
print('_on_event_test')
async def send(self):
await self._demo.send()
async def run():
test = LockTest()
await test.send()
if __name__ == '__main__':
asyncio.run(run())