initial commit

This commit is contained in:
Nicolas Duhamel 2020-12-28 11:40:54 +01:00
commit fafdb2753d
5 changed files with 46 additions and 0 deletions

8
.gitignore vendored Normal file
View 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
View File

@ -0,0 +1,4 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

12
setup.cfg Normal file
View 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

2
setup.py Normal file
View File

@ -0,0 +1,2 @@
import setuptools
setuptools.setup()

View 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