Skip to content

Replace fcntl for Windows compatibility #12

@monatis

Description

@monatis

When I installed the package and ran the first command with colab auth login on Windows, it fails with "no module named fcntl". As I can see from the code, it's used for file locking operations:

with open(self.path, "r") as f:
fcntl.flock(f, fcntl.LOCK_SH)
try:
yield f
finally:
fcntl.flock(f, fcntl.LOCK_UN)
@contextlib.contextmanager
def _lock_exclusive(self) -> Iterator[IO]:
with open(self.path, "a+") as f:
fcntl.flock(f, fcntl.LOCK_EX)
try:
yield f
finally:
fcntl.flock(f, fcntl.LOCK_UN)

It can be replaced with filelock, which is cross-platform, or import winfcntl conditionally on Windows. I can raise a PR if it's ok to you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions