I try to perform multi-process analysis in the code to analyze the data of a certain file, but the code cannot perform the join normally, and there is no method to perform multiprocessing.Process. May I ask what I did wrong, please forgive me for not knowing how to format in the google group So I formatted it manually. Thank you very much for reading my question. Below is my test code
#coding:utf-8
from prometheus_client
import generate_latest, CollectorRegistry
from prometheus_client.core
import CollectorRegistry
from flask
import Response,Flask
import multiprocessing
class CustomCollector(object):
def get_data(self,data):
print(data)
def collect(self):
plist = []
for x in range(30):
p = multiprocessing.Process(target=self.get_data,args=("test",))
plist.append(p)
p.start()
for p in plist:
p.join()
print('Process close')
def rundata():
REGISTRY = CollectorRegistry(auto_describe=False)
REGISTRY.register(CustomCollector())
coll = CustomCollector()
coll.collect()
return Response(generate_latest(REGISTRY), mimetype="text/plain")
rundata()