Skip to content

Commit 6c2793e

Browse files
threading: extend
1 parent 005f1c0 commit 6c2793e

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

internal_filesystem/lib/threading.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
try:
2-
import _thread
3-
except ImportError:
4-
_thread = None
1+
import _thread
2+
3+
class Thread:
4+
def __init__(self, group=None, target=None, name=None, args=(), kwargs=None):
5+
self.target = target
6+
self.args = args
7+
self.kwargs = {} if kwargs is None else kwargs
8+
9+
def start(self):
10+
_thread.start_new_thread(self.run, ())
11+
12+
def run(self):
13+
self.target(*self.args, **self.kwargs)
14+
515

616
class Lock:
717
def __init__(self):
8-
self._lock = _thread.allocate_lock() if _thread else None
18+
self._lock = _thread.allocate_lock()
919

1020
def __enter__(self):
1121
if self._lock:

0 commit comments

Comments
 (0)