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("./qdata_coins", '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.get_erc20,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/590092af-3cb7-4d8e-8d88-9d64c25718e2n%40googlegroups.com.