开发者

Python Multiprocessing: socket error timeout while remote connection to a Manager

newcomer and first ever question here.

I am using the multiprocessing module of Python which is currently creating a Manager and a couple (45) processes on my localhost. My Manager is set up as following:

manager = QueueManager(address=('', 50000), authkey='abracadabra')
manager.get_server().serve_forever()

I want also to create some other client processes remotely on another computer. So, let's say my IP is a.b.c.d, the Manager of the client in the remote computer is set up as following:

manager = QueueManager(address=('a.b.c.d', 50000), authkey='abracadabra')
manager.connect()

(yes, it's copy-pasted from the documentation).

However, I run the server and all 45 processes in localhost are fine, then I run the remote client and I get this:

Traceback (most recent call last):
  File "govmap-parallel-crawler-client.py", line 144, in <module>
    manager.connect()
  File "/usr/lib/python2.6/multiprocessing/managers.py", line 474, in connect
    conn = Client(self._address, authkey=self._authkey)
  File "/usr/lib/python2.6/multipro开发者_开发百科cessing/connection.py", line 134, in Client
    c = SocketClient(address)
  File "/usr/lib/python2.6/multiprocessing/connection.py", line 252, in SocketClient
    s.connect(address)
  File "<string>", line 1, in connect
socket.error: [Errno 110] Connection timed out

Both computers can ping and ssh each other without problems.

My guess: there is one (or two!) firewall in between making the connection impossible. Is this correct?

If yes: is there a way to use a safe known port in order to avoid the firewall or maybe a more polite solution?

If no: what is happening?

Thanks!!


Use an ssh tunnel for interconnect? E.g on client:

ssh a.b.c.d -L12345:localhost:50000

If the client connects to localhost port 12345, it should be tunnelled to a.b.c.d port 50000.

EDIT: Of course, using an SSH tunnel might not be the best solution in a production environment, but at least it lets you eliminate other issues.


As defined by your snippet the server listens only on localhost (127.0.0.1) and not (a.b.c.d) thus you cannot connect from remote client.

To do so use:

manager = QueueManager(address=('a.b.c.d', 50000), authkey='abracadabra')
manager.get_server().serve_forever()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜