프로세스간에 통신하고 싶었습니다 (한 프로세스는 무언가를하고 다른 프로세스로 결과를 보냅니다). 그래서 나는이 코드를 사용 :다른 컴퓨터의 프로세스 간 통신
서버 :
from multiprocessing.connection import Listener
address = ('localhost', 6000) # family is deduced to be 'AF_INET'
listener = Listener(address, authkey='secret password')
conn = listener.accept()
print 'connection accepted from', listener.last_accepted
while True:
msg = conn.recv()
# do something with msg
if msg == 'close':
conn.close()
break
listener.close()
클라이언트 :
from multiprocessing.connection import Client
address = ('localhost', 6000)
conn = Client(address, authkey='secret password')
conn.send('close')
conn.close()
(출처 : interprocess communication in python)
그리고 그것은 마법처럼 작동합니다. 하지만 다른 컴퓨터에서이 두 프로그램을 실행하고 싶었습니다. Comp. A 나는이 두 가지 프로그램을 가지고 있습니다. 나는 Wifi Lan (ssh 연결 사용)에 의해 Comp B에서 Comp A에 연결하고이 2 개의 프로그램을 실행합니다 (즉, Comp A에서 실행 중임). 그러나 서로 연결하지 않습니다. 나는 "localhost"대신에 wifi lan address (192.168.x.x)를 사용해 보았지만 둘 다 작동하지 않았다. 이 두 프로그램을 연결할 수 있도록 "localhost"대신 어떤 매개 변수를 사용해야합니까? 또는 이것을 수행하는 가장 쉬운 방법은 무엇입니까? 건배!