mirror of
https://github.com/SantaSpeen/winmutex.git
synced 2025-07-01 23:47:47 +00:00
[>] pywinmutex > winmutex
This commit is contained in:
parent
420e352745
commit
f2ed9af99f
16
README.md
16
README.md
@ -7,16 +7,17 @@ A simple Python library to create and manage Windows mutexes.
|
|||||||
You can install the library using pip:
|
You can install the library using pip:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pip install pywinmutex
|
pip install winmutex
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Basic Example
|
### Basic Example
|
||||||
```python
|
|
||||||
from pywinmutex import WindowsMutex
|
|
||||||
|
|
||||||
mutex = WindowsMutex("anidev/pywinmutex/simple", True) # Name may be any string
|
```python
|
||||||
|
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
|
mutex.timeout = 2500 # Set a timeout of 2.5 seconds
|
||||||
|
|
||||||
with mutex:
|
with mutex:
|
||||||
@ -27,10 +28,11 @@ print(f"[I] Mutex({mutex}) released. Exiting...")
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Legacy
|
### Legacy
|
||||||
```python
|
|
||||||
from pywinmutex import WindowsMutex
|
|
||||||
|
|
||||||
mutex = WindowsMutex("anidev/pywinmutex/acquire", True) # Name may be any string
|
```python
|
||||||
|
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
|
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.")
|
print(f"[W] Mutex({mutex}) already exists or acquire timeout exceeded.")
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from pywinmutex import WindowsMutex
|
from winmutex import WindowsMutex
|
||||||
|
|
||||||
mutex = WindowsMutex("anidev/pywinmutex/acquire", True) # Name may be any string
|
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
|
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.")
|
print(f"[W] Mutex({mutex}) already exists or acquire timeout exceeded.")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from pywinmutex import WindowsMutex
|
from winmutex import WindowsMutex
|
||||||
|
|
||||||
mutex_name = "anidev.myapp.mutex.{}" # Name constructor
|
mutex_name = "anidev.myapp.mutex.{}" # Name constructor
|
||||||
mutex = WindowsMutex(mutex_name.format(0), True)
|
mutex = WindowsMutex(mutex_name.format(0), True)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from pywinmutex import WindowsMutex
|
from winmutex import WindowsMutex
|
||||||
|
|
||||||
mutex = WindowsMutex("anidev/pywinmutex/simple", True) # Name may be any string
|
mutex = WindowsMutex("anidev/winmutex/simple", True) # Name may be any string
|
||||||
mutex.timeout = 2500 # Set a timeout of 2.5 seconds
|
mutex.timeout = 2500 # Set a timeout of 2.5 seconds
|
||||||
|
|
||||||
with mutex:
|
with mutex:
|
||||||
|
2
main.py
2
main.py
@ -1,4 +1,4 @@
|
|||||||
from pywinmutex import WindowsMutex
|
from winmutex import WindowsMutex
|
||||||
|
|
||||||
mutex_name = "anidev.myapp.mutex.{}" # Name constructor
|
mutex_name = "anidev.myapp.mutex.{}" # Name constructor
|
||||||
mutex = WindowsMutex(mutex_name.format(0), True)
|
mutex = WindowsMutex(mutex_name.format(0), True)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "pywinmutex"
|
name = "winmutex"
|
||||||
version = "0.1.0"
|
version = "1.0.0"
|
||||||
description = "Simple handling mutexes with pywin32"
|
description = "Simple handling mutexes with pywin32"
|
||||||
authors = [
|
authors = [
|
||||||
{name = "SantaSpeen",email = "santaspeen@gmail.com"}
|
{name = "SantaSpeen",email = "santaspeen@gmail.com"}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user