我想运行两个函数而不等待第一个函数完成。我需要运行一个函数“ListeningToReceive”使端口监听接收来自远程代理的数据,当监听该端口时,它执行第二个函数“RunRemoteAgents”来运行远程代理,以使它们向侦听端口发送数据。 我使用线程,但它似乎不起作用,它只是让端口监听,而不执行第二个函数
#!/usr/bin/python
import threading
def ListeningToReceive():
print "The port is open to receive data"
def RunRemoteAgensts():
print "Running remote agents to send Data to the open port here"
if __name__ == "__main__":
thread1 = threading.Thread(target=ListeningToReceive)
thread2 = threading.Thread(target=RunRemoteAgents)
thread1.start()
thread2.start()
请改用多处理:
相关问题 更多 >
编程相关推荐