Skip to content

Commit a95b8b5

Browse files
committed
stability improvements for multiprocessing, added queue for handling of return values
1 parent a6bab03 commit a95b8b5

File tree

12 files changed

+15
-17
lines changed

12 files changed

+15
-17
lines changed

VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
14.4.5 experimental
1+
14.4.6 experimental

changelog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,8 @@ Version 14.3.3 BETA
1818
Version 14.4.4 BETA
1919
- [minor] Updated module requests to ver 2.3.4 which also includes a new version of urllib3
2020

21+
Version 14.4.6 experimental
22+
- [major] added multiprocessing support
23+
- [minor] some changes to the sensor's get_data function, especially the handling of the return values. Now handled by a queue.
24+
- [minor] stability improvements to multiprocessing
25+

probe.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ def main():
113113
if str(json_response) != '[]':
114114
json_response_chunks = [json_response[i:i + 10] for i in range(0, len(json_response), 10)]
115115
procs = []
116-
out_queue = multiprocessing.Queue()
116+
117117
for element in json_response_chunks:
118+
out_queue = multiprocessing.Queue()
118119
for part in element:
119120
if config['debug']:
120121
logging.debug(part)
@@ -130,10 +131,11 @@ def main():
130131
for i in range(len(procs)):
131132
json_payload_data.append(out_queue.get())
132133
for p in procs:
133-
p.join()
134+
p.join(2)
134135
procs = []
136+
p.terminate()
135137
del p
136-
138+
del out_queue
137139
url_data = mini_probe.create_url(config, 'data')
138140
try:
139141
request_data = requests.post(url_data, data=json.dumps(json_payload_data), verify=False)
@@ -149,7 +151,7 @@ def main():
149151
time.sleep((int(config['baseinterval']) * (9 / len(json_response))))
150152
else:
151153
time.sleep(int(config['baseinterval']) / 2)
152-
del out_queue
154+
153155
else:
154156
logging.info("Nothing to do. Waiting for %s seconds." % (int(config['baseinterval']) / 3))
155157
time.sleep(int(config['baseinterval']) / 3)

sensors/cpuload.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def get_data(data, out_queue):
7878
del cpuload
7979
gc.collect()
8080
out_queue.put(data)
81-
return data
8281

8382
@staticmethod
8483
def read_cpu(path):

sensors/diskspace.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ def get_data(data, out_queue):
7777
del diskspace
7878
gc.collect()
7979
out_queue.put(data)
80-
return data
8180

8281
def read_disk(self):
8382
disks = []

sensors/http.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,3 @@ def get_data(data, out_queue):
205205
del http
206206
gc.collect()
207207
out_queue.put(data)
208-
return data

sensors/memory.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def get_data(data, out_queue):
7878
del memory
7979
gc.collect()
8080
out_queue.put(data)
81-
return data
8281

8382
def read_memory(self, path):
8483
mem = open(path, "r")

sensors/ping.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,3 @@ def get_data(data, out_queue):
158158
del ping
159159
gc.collect()
160160
out_queue.put(data)
161-
return data

sensors/port.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,4 @@ def get_data(data, out_queue):
134134
}
135135
del port
136136
gc.collect()
137-
out_queue.put(data)
138-
return data
137+
out_queue.put(data)

sensors/probehealth.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ def get_data(data, out_queue):
7979
"channel": probedata
8080
}
8181
out_queue.put(data)
82-
return data
8382

8483
def read_memory(self, path):
8584
mem = open(path, "r")

0 commit comments

Comments
 (0)