Skip to content

Instantly share code, notes, and snippets.

@michalc
Last active November 22, 2018 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michalc/3a50e77256079ea413746587160b0dc1 to your computer and use it in GitHub Desktop.
Save michalc/3a50e77256079ea413746587160b0dc1 to your computer and use it in GitHub Desktop.
Path lock using a global exclusive lock
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