Donate CPU: let the server remember latest packages when restarting
This commit is contained in:
parent
c6369e6519
commit
f88326c51f
|
@ -304,6 +304,8 @@ def server(server_address_port, packages, packageIndex, resultPath):
|
||||||
sock.listen(1)
|
sock.listen(1)
|
||||||
|
|
||||||
latestResults = []
|
latestResults = []
|
||||||
|
with open('latest.txt', 'rt') as f:
|
||||||
|
latestResults = f.read().strip().split(' ')
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
# wait for a connection
|
# wait for a connection
|
||||||
|
@ -362,13 +364,14 @@ def server(server_address_port, packages, packageIndex, resultPath):
|
||||||
if res and url in packages:
|
if res and url in packages:
|
||||||
print('results added for package ' + res.group(1))
|
print('results added for package ' + res.group(1))
|
||||||
filename = resultPath + '/' + res.group(1)
|
filename = resultPath + '/' + res.group(1)
|
||||||
f = open(filename, 'wt')
|
with open(filename, 'wt') as f:
|
||||||
f.write(strDateTime() + '\n' + data)
|
f.write(strDateTime() + '\n' + data)
|
||||||
f.close()
|
|
||||||
# track latest added results..
|
# track latest added results..
|
||||||
if len(latestResults) >= 20:
|
if len(latestResults) >= 20:
|
||||||
latestResults = latestResults[1:]
|
latestResults = latestResults[1:]
|
||||||
latestResults.append(filename)
|
latestResults.append(filename)
|
||||||
|
with open('latest.txt', 'wt') as f:
|
||||||
|
f.write(' '.join(latestResults))
|
||||||
else:
|
else:
|
||||||
print('[' + strDateTime() + '] invalid command: ' + firstLine)
|
print('[' + strDateTime() + '] invalid command: ' + firstLine)
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|
Loading…
Reference in New Issue