-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
31 lines (24 loc) · 776 Bytes
/
example.py
File metadata and controls
31 lines (24 loc) · 776 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
# !usr/bin/python
import os, socket, subprocess, sys, time, signal
server = None
caches = []
cachesfd = []
try:
host = socket.gethostname()
host = socket.gethostbyname(host)
#print(f'Connect browser to {host}:5001')
server = subprocess.Popen(f'{sys.executable} HttpServer.py', shell=True)
time.sleep(5)
for i in range(5):
f = open(f'cache{i}.txt', 'w+')
cachesfd.append(f)
caches.append(subprocess.Popen(f'{sys.executable} cache.py -ns {host}:5000', shell=True, stdout=f, stderr=f))
time.sleep(2)
while True: pass
except KeyboardInterrupt as e:
#server.terminate()
if server:
os.kill(server.pid,signal.SIGKILL)
for i in caches:
#i.terminate()
os.kill(i.pid, signal.SIGKILL)