From 6c2793e93537c8a54601f07c0c1a85a90adb2a6a Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Mon, 19 May 2025 14:44:28 +0200 Subject: [PATCH] threading: extend --- internal_filesystem/lib/threading.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/internal_filesystem/lib/threading.py b/internal_filesystem/lib/threading.py index 31c04ec7..dc62621e 100644 --- a/internal_filesystem/lib/threading.py +++ b/internal_filesystem/lib/threading.py @@ -1,11 +1,21 @@ -try: - import _thread -except ImportError: - _thread = None +import _thread + +class Thread: + def __init__(self, group=None, target=None, name=None, args=(), kwargs=None): + self.target = target + self.args = args + self.kwargs = {} if kwargs is None else kwargs + + def start(self): + _thread.start_new_thread(self.run, ()) + + def run(self): + self.target(*self.args, **self.kwargs) + class Lock: def __init__(self): - self._lock = _thread.allocate_lock() if _thread else None + self._lock = _thread.allocate_lock() def __enter__(self): if self._lock: