-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPU-bound.py
More file actions
35 lines (23 loc) · 814 Bytes
/
CPU-bound.py
File metadata and controls
35 lines (23 loc) · 814 Bytes
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 hashlib import md5
from random import choice
import concurrent.futures
def single_process():
while True:
s = "".join([choice("0123456789") for i in range(50)])
h = md5(s.encode('utf8')).hexdigest()
if h.endswith("00000"):
print(s, h)
#single_process()
def find_coins():
while True:
s = "".join([choice("0123456789") for i in range(50)])
h = md5(s.encode('utf8')).hexdigest()
if h.endswith("00000"):
print(s, h)
def main():
max_workers = int(input("Введите число процессоров: "))
with concurrent.futures.ProcessPoolExecutor(max_workers=max_workers) as executor:
for i in range(1, max_workers + 1):
executor.submit(find_coins, i)
if __name__ == '__main__':
main()