我有一个SimpleXMLRPCServer
与此类似的基于 Python 的:
from multiprocessing import Process
from SimpleXMLRPCServer import SimpleXMLRPCServer
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
import SocketServer
class RPCThreading(SocketServer.ThreadingMixIn, SimpleXMLRPCServer):
pass
# Restrict to a particular path.
class RequestHandler(SimpleXMLRPCRequestHandler):
rpc_paths = ('/RPC2',)
def main():
server = RPCThreading(('127.0.0.1', 8000), requestHandler=RequestHandler)
server.register_function(tester1)
server.register_function(tester2)
print("Server running...")
server.serve_forever()
def tester1(id):
p = Process(target=my_func1, args=(id,))
p.start()
return True
def tester2(id):
p = Process(target=my_func2, args=(id,))
p.start()
return True
我想实现一种方法来跟踪当前正在执行的并发进程数量tester1
和tester2
,并且如果仍在执行的最大(用户定义)数量以上,则将每个新请求排队并在数量下降时执行低于阈值。
也许Pool
每个功能都有一个共享?