Skip to content

5 second delay upon resolving the local hostname with "socket.getfqdn()" #1900

@kid-alan

Description

@kid-alan

I'm using a fabric2 module to set-up connections and execute command on the remote host. I noticed that every time I create a connection I get a 10 second delay. Profiling the code I pin-pointed the delay to the "socket.getfqdn()" call in the "paramiko/config.py"

It took 5 second to execute on my M1 mac. Digging deeper I found that the reason is the hostname culprit:

$ scutil --get LocalHostName
my-mac
$ hostname
my-mac.local

After running this command, the hostnames are set the same, without the ".local" extension, and the problem is solved:

scutil --set HostName $(scutil --get LocalHostName)

I understand, that the fundamental issue is in the socket.getfqdn() function, not Paramiko, but maybe it is worth to at least to design some workaround, to avoid such a long delay. I am quite new to the python and this is my first time ever submitting the issue, so please feel free to point out any problems with the issue description. I just want to be helpful!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions