I use prometheus client to process back-end data in multiple processes, and
multiple processes cannot join during operation. Below is my code,Why not
wait at the position of p.join()?
class CustomCollectorA(object):
def collect(self):
with open("./data", 'r') as load_f:
load_dict = json.load(load_f)
n = len(load_dict) // 100
i = iter(load_dict.items())
lists = []
plist = []
for x in range(30):
d = dict(itertools.islice(i, n))
lists.append(d)
for li in lists:
if len(li) ==0:
lists.remove(li)
if li == "{}":
lists.remove(li)
else:
p = multiprocessing.Process(target=self.data,args=(li,))
plist.append(p)
p.start()
for p in plist:
p.join()
print('Process close')
@app.route("/getdata")
def getdata():
REGISTRY = CollectorRegistry(auto_describe=False)
REGISTRY.register(CustomCollectorA())
coll = CustomCollectorA()
coll.collect()
return Response(generate_latest(REGISTRY), mimetype="text/plain")
if __name__ == "__main__":
app.run(host='127.0.0.1',port=22090)
--
You received this message because you are subscribed to the Google Groups
"Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-developers/97f9d320-8834-4e21-82d3-c56ce5d6e20bn%40googlegroups.com.