Last active
November 22, 2018 19:23
-
-
Save michalc/3a50e77256079ea413746587160b0dc1 to your computer and use it in GitHub Desktop.
Path lock using a global exclusive lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import contextlib | |
class PathLock(): | |
def __init__(self): | |
self.lock = asyncio.Lock() | |
@contextlib.asynccontextmanager | |
async def __call__(self, read, write): | |
async with self.lock: | |
yield |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment