def maxpackages():
while max_packages:
print("maxpackages")
# Loop to send amount from config file of msg to server
for x in range(parser.getint('MaximumPackages', 'MaximumPackages')):
msg = 'maxpackages'
mp = multiprocessing.Process(target=sock.sendto, args=(msg.encode(), server_address))
mp.start()
resp, server = sock.recvfrom(4096)
server_resp = resp.decode()
print(server_resp)
sock.close()
break
错误消息: RuntimeError: 尝试在启动新进程之前启动新进程。 当前进程已完成其引导阶段。
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.