-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContainer.py
35 lines (28 loc) · 936 Bytes
/
Container.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from random import randrange
from typing import Dict
from hashlib import md5
from time import sleep
class ThreadContainerLock:
def __init__(self, dicts: list) -> None:
self.dicts: list[list[Dict[str, tuple]]] = [
[{md5(f"{randrange(0,9999999)}".encode()).hexdigest(): d}] for d in dicts
]
self.currentIndex = 0
def GetNext(self) -> list[Dict[str, tuple]] | None:
try:
self.currentIndex += 1
return list(list(self.dicts[self.currentIndex - 1][0].items())[0])[1]
except:
return None
def isNotNone(self) -> bool:
try:
self.dicts[self.currentIndex - 1]
return True
except:
return False
class RestartRouterLock:
def __init__(self) -> None:
self.isLocked = False
def GetNext(self):
while self.isLocked:
sleep(1)