initial commit
This commit is contained in:
commit
fafdb2753d
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Source for the following rules: https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
|
||||
*.egg-info/
|
4
pyproject.toml
Normal file
4
pyproject.toml
Normal file
@ -0,0 +1,4 @@
|
||||
[build-system]
|
||||
requires = ["setuptools", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
12
setup.cfg
Normal file
12
setup.cfg
Normal file
@ -0,0 +1,12 @@
|
||||
[metadata]
|
||||
name = citadel.utils
|
||||
version = 0.0.1
|
||||
|
||||
[options]
|
||||
package_dir =
|
||||
=src
|
||||
packages = find_namespace:
|
||||
|
||||
[options.packages.find]
|
||||
where = src
|
||||
|
20
src/citadel/utils/__init__.py
Normal file
20
src/citadel/utils/__init__.py
Normal file
@ -0,0 +1,20 @@
|
||||
import threading
|
||||
|
||||
class TimeoutLock:
|
||||
def __init__(self, interval: int):
|
||||
self._interval = interval
|
||||
self._locked = False
|
||||
self._timer = None
|
||||
|
||||
def lock(self):
|
||||
self._locked = True
|
||||
if self._timer is not None and self._timer.is_alive():
|
||||
self._timer.cancel()
|
||||
self._timer = threading.Timer(self._interval, self._unlock).start()
|
||||
|
||||
def _unlock(self):
|
||||
self._locked = False
|
||||
|
||||
@property
|
||||
def is_locked(self):
|
||||
return self._locked
|
Loading…
x
Reference in New Issue
Block a user