Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
constants.py59 linesDownload Raw Back to portalocker
1'''2Locking constants3 4Lock types:5 6- `EXCLUSIVE` exclusive lock7- `SHARED` shared lock8 9Lock flags:10 11- `NON_BLOCKING` non-blocking12 13Manually unlock, only needed internally14 15- `UNBLOCK` unlock16'''17import enum18import os19 20# The actual tests will execute the code anyhow so the following code can21# safely be ignored from the coverage tests22if os.name == 'nt':  # pragma: no cover23    import msvcrt24 25    #: exclusive lock26    LOCK_EX = 0x127    #: shared lock28    LOCK_SH = 0x229    #: non-blocking30    LOCK_NB = 0x431    #: unlock32    LOCK_UN = msvcrt.LK_UNLCK  # type: ignore33 34elif os.name == 'posix':  # pragma: no cover35    import fcntl36 37    #: exclusive lock38    LOCK_EX = fcntl.LOCK_EX39    #: shared lock40    LOCK_SH = fcntl.LOCK_SH41    #: non-blocking42    LOCK_NB = fcntl.LOCK_NB43    #: unlock44    LOCK_UN = fcntl.LOCK_UN45 46else:  # pragma: no cover47    raise RuntimeError('PortaLocker only defined for nt and posix platforms')48 49 50class LockFlags(enum.IntFlag):51    #: exclusive lock52    EXCLUSIVE = LOCK_EX53    #: shared lock54    SHARED = LOCK_SH55    #: non-blocking56    NON_BLOCKING = LOCK_NB57    #: unlock58    UNBLOCK = LOCK_UN59 
codekingpro/portable-devtools · Team Ai