SantaSpeen f296b8e1bc [^] version 1.0.1
[+] classifiers
[+] urls
2025-04-02 14:17:18 +03:00
2025-04-02 14:03:37 +03:00
2025-04-02 14:16:52 +03:00
2025-04-02 12:04:27 +03:00
2025-04-02 12:01:09 +03:00
2025-04-02 14:03:37 +03:00
2025-04-02 12:13:17 +03:00
2025-04-02 14:17:18 +03:00
2025-04-02 14:15:48 +03:00

WinMutex

A simple Python library to create and manage Windows mutexes.

Installation

You can install the library using pip:

pip install winmutex

Usage

Basic Example

from winmutex import WindowsMutex

mutex = WindowsMutex("anidev/winmutex/simple", True)  # Name may be any string
mutex.timeout = 2500  # Set a timeout of 2.5 seconds

with mutex:
    print(f"[I] Mutex({mutex}) acquired.")
    input("Enter to release the mutex and exit> ")

print(f"[I] Mutex({mutex}) released. Exiting...")

Legacy

from winmutex import WindowsMutex

mutex = WindowsMutex("anidev/winmutex/acquire", True)  # Name may be any string

if not mutex.acquire(5000):  # Acquire the mutex with a timeout of 5 seconds; None for no timeout
    print(f"[W] Mutex({mutex}) already exists or acquire timeout exceeded.")
    exit(1)

# Do some work while holding the mutex

print(f"[I] Mutex({mutex}) acquired.")
input("Enter to release the mutex and exit> ")

# Release the mutex
mutex.release()
print(f"[I] Mutex({mutex}) released. Exiting...")

License

This project is licensed under the MIT License. See the LICENSE file for details.

Description
Python lib for handling mutexes with pywin32
Readme MIT 36 KiB
Languages
Python 100%