-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.py
More file actions
55 lines (38 loc) · 1.14 KB
/
main.py
File metadata and controls
55 lines (38 loc) · 1.14 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import random
from typing import Awaitable
from asyncio import (
create_task,
gather,
sleep,
run
)
from loguru import logger
from config import *
from src.utils.data.mappings import module_handlers
from src.utils.wrappers.decorators import check_gas
from src.utils.data.helper import (
private_keys,
active_module,
)
@check_gas
async def process_task(private_key: str, pattern: str) -> None:
await module_handlers[pattern](private_key)
async def main() -> None:
tasks = []
random.shuffle(private_keys)
for private_key in private_keys:
patterns = active_module.copy()
if RANDOMIZE:
random.shuffle(patterns)
for pattern in patterns:
task = create_task(process_task(private_key, pattern))
tasks.append(task)
await task
time_to_sleep = random.randint(MIN_PAUSE, MAX_PAUSE)
logger.info(f'Sleeping {time_to_sleep} seconds...')
await sleep(time_to_sleep)
await gather(*tasks)
def start_event_loop(awaitable: Awaitable[None]) -> None:
run(awaitable)
if __name__ == '__main__':
start_event_loop(main())