Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions distributed/comm/inproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from distributed.comm.core import BaseListener, Comm, CommClosedError, Connector
from distributed.comm.registry import Backend, backends
from distributed.protocol.serialize import _nested_deserialize
from distributed.utils import get_ip

logger = logging.getLogger(__name__)

Expand All @@ -38,10 +37,7 @@ def __init__(self):
@property
def ip(self):
if not self._ip:
try:
self._ip = get_ip()
except OSError:
self._ip = "127.0.0.1"
self._ip = "127.0.0.1"
return self._ip

def add_listener(self, addr, listener):
Expand Down
7 changes: 3 additions & 4 deletions distributed/comm/tests/test_comms.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_get_address_host(tcp):
f = get_address_host

assert f("tcp://127.0.0.1:123") == "127.0.0.1"
assert f("inproc://%s/%d/123" % (get_ip(), os.getpid())) == get_ip()
assert f("inproc://127.0.0.1/%d/123" % os.getpid()) == "127.0.0.1"


def test_resolve_address(tcp):
Expand Down Expand Up @@ -201,7 +201,7 @@ def test_get_local_address_for(tcp):
if has_ipv6():
assert f("tcp://[::1]:123") == "tcp://[::1]"

inproc_arg = "inproc://%s/%d/444" % (get_ip(), os.getpid())
inproc_arg = "inproc://127.0.0.1/%d/444" % os.getpid()
inproc_res = f(inproc_arg)
assert inproc_res.startswith("inproc://")
assert inproc_res != inproc_arg
Expand Down Expand Up @@ -586,12 +586,11 @@ def checker(loc):


def inproc_check():
expected_ip = get_ip()
expected_pid = os.getpid()

def checker(loc):
ip, pid, suffix = loc.split("/")
assert ip == expected_ip
assert ip == "127.0.0.1"
assert int(pid) == expected_pid

return checker
Expand Down
22 changes: 22 additions & 0 deletions distributed/deploy/tests/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,28 @@ def test_transports_inproc(loop):
assert e.submit(inc, 4).result() == 5


def test_transports_inproc_does_not_discover_external_ip(loop):
import distributed.comm.inproc

distributed.comm.inproc.global_manager._ip = None
with (
mock.patch(
"distributed.comm.inproc.get_ip",
side_effect=AssertionError("inproc should not discover an external IP"),
create=True,
),
LocalCluster(
n_workers=1,
processes=False,
silence_logs=False,
dashboard_address=":0",
loop=loop,
) as c,
):
assert c.scheduler_address.startswith("inproc://127.0.0.1/")
assert c.workers[0].address.startswith("inproc://127.0.0.1/")


def test_transports_tcp(loop):
# Have nannies => need TCP
with LocalCluster(
Expand Down
4 changes: 2 additions & 2 deletions distributed/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,12 @@ async def listen_on(cls, *args, **kwargs):

async with listen_on(Server, "inproc://") as server:
inproc_addr1 = server.address
assert inproc_addr1.startswith("inproc://%s/%d/" % (get_ip(), os.getpid()))
assert inproc_addr1.startswith("inproc://127.0.0.1/%d/" % os.getpid())
await assert_can_connect(inproc_addr1)

async with listen_on(Server, "inproc://") as server2:
inproc_addr2 = server2.address
assert inproc_addr2.startswith("inproc://%s/%d/" % (get_ip(), os.getpid()))
assert inproc_addr2.startswith("inproc://127.0.0.1/%d/" % os.getpid())
await assert_can_connect(inproc_addr2)

await assert_can_connect(inproc_addr1)
Expand Down
Loading