-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy patht1.py
executable file
·70 lines (57 loc) · 1.26 KB
/
t1.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#! /usr/bin/env python3
import os
from typing import Any
from whoisdomain import ProcFunc
def remoteFunc(
conn: Any,
max_requests: int,
) -> None:
n = 0
while True:
n += 1
try:
request = conn.recv()
reply = f"The name of the given continent is: {request}. Says process {os.getpid()} with count {n}"
conn.send(reply)
except EOFError as e:
_ = e
exit(0)
if n >= max_requests:
break
def main() -> None:
names = [
"Africa",
"America",
"Antarctica",
"Atlantis",
"Australie",
"Azia",
"Europe",
"Heaven",
"Hell",
"Mu",
"Nirvana",
"Purgatory",
]
restart_after_count: int = 50
pf: ProcFunc = ProcFunc()
f = pf.makeHandler(remoteFunc, restart_after_count)
n = 0
while True:
n += 1
for item in names:
v = f(item)
print(v)
if n >= 26:
break
f = pf.makeHandler(remoteFunc, restart_after_count)
n = 0
while True:
n += 1
for item in names:
v = f(item)
print(v)
if n >= 26:
break
if __name__ == "__main__":
main()