huggingface / knockknock

🚪✊Knock Knock: Get notified when your training ends with only two additional lines of code
MIT License
2.78k stars 233 forks source link

socket.gaierror: [Errno -3] Temporary failure in name resolution #12

Closed mikelkl closed 5 years ago

mikelkl commented 5 years ago

Hi there,

When I used the email sender example like below:

from knockknock import email_sender

@email_sender(recipient_email="<your_email@address.com>", sender_email="<grandma's_email@gmail.com>")
def train_your_nicest_model(your_nicest_parameters):
    import time
    time.sleep(10000)
    return {'loss': 0.9} # Optional return value

I got below error:

socket.gaierror: [Errno -3] Temporary failure in name resolution

Any suggestion for this problem?

Thanks

VictorSanh commented 5 years ago

Hello @mikelkl, It sounds like something wrong is happening when trying to get the host name (the name of your machine/server). Can you try to do a import socket; socket.gethostname()?

mikelkl commented 5 years ago

Hi @VictorSanh,

I got ubuntu as hostname.

VictorSanh commented 5 years ago

Hmmmm that's strange...

Could you clone the repo and launch it from the repo with a stupid code like this one:

from knockknock import email_sender
import time
@email_sender(recipient_email="<your_email@address.com>", sender_email="<grandma's_email@gmail.com>")
def train_your_nicest_model():
    time.sleep(1)
    return 0

train_your_nicest_model()

so that I have the exact line that triggers the error? Do you mind also sharing some specificities of your configurations?

mikelkl commented 5 years ago

Hi @VictorSanh ,

Below is the traceback:

gaierror                                  Traceback (most recent call last)
<ipython-input-3-3b35cee98aac> in <module>()
      6     return 0
      7
----> 8 train_your_nicest_model()

~/projects/misc/knockknock/knockknock/email_sender.py in wrapper_sender(*args, **kwargs)
     48                             'Main call: %s' % func_name,
     49                             'Starting date: %s' % start_time.strftime(DATE_FORMAT)]
---> 50                 yag_sender.send(recipient_email, 'Training has started 🎬', contents)
     51
     52             try:

/home/ai/anaconda3/lib/python3.6/site-packages/yagmail/sender.py in send(self, to, subject, contents, attachments, cc, bcc, preview_only, headers, newline_to_break)
    145     ):
    146         """ Use this to send an email with gmail"""
--> 147         self.login()
    148         recipients, msg_string = self.prepare_send(
    149             to, subject, contents, attachments, cc, bcc, headers, newline_to_break

/home/ai/anaconda3/lib/python3.6/site-packages/yagmail/sender.py in login(self)
    244             self._login_oauth2(self.credentials)
    245         else:
--> 246             self._login(self.credentials)
    247
    248

/home/ai/anaconda3/lib/python3.6/site-packages/yagmail/sender.py in _login(self, password)
    190         connection to the SMTP server was closed by the user.
    191         """
--> 192         self.smtp = self.connection(self.host, self.port, **self.kwargs)
    193         self.smtp.set_debuglevel(self.debuglevel)
    194         if self.starttls:

/home/ai/anaconda3/lib/python3.6/smtplib.py in __init__(self, host, port, local_hostname, keyfile, certfile, timeout, source_address, context)
   1029             self.context = context
   1030             SMTP.__init__(self, host, port, local_hostname, timeout,
-> 1031                     source_address)
   1032
   1033         def _get_socket(self, host, port, timeout):

/home/ai/anaconda3/lib/python3.6/smtplib.py in __init__(self, host, port, local_hostname, timeout, source_address)
    249
    250         if host:
--> 251             (code, msg) = self.connect(host, port)
    252             if code != 220:
    253                 self.close()

/home/ai/anaconda3/lib/python3.6/smtplib.py in connect(self, host, port, source_address)
    334         if self.debuglevel > 0:
    335             self._print_debug('connect:', (host, port))
--> 336         self.sock = self._get_socket(host, port, self.timeout)
    337         self.file = None
    338         (code, msg) = self.getreply()

/home/ai/anaconda3/lib/python3.6/smtplib.py in _get_socket(self, host, port, timeout)
   1035                 self._print_debug('connect:', (host, port))
   1036             new_socket = socket.create_connection((host, port), timeout,
-> 1037                     self.source_address)
   1038             new_socket = self.context.wrap_socket(new_socket,
   1039                                                   server_hostname=self._host)

/home/ai/anaconda3/lib/python3.6/socket.py in create_connection(address, timeout, source_address)
    702     host, port = address
    703     err = None
--> 704     for res in getaddrinfo(host, port, 0, SOCK_STREAM):
    705         af, socktype, proto, canonname, sa = res
    706         sock = None

/home/ai/anaconda3/lib/python3.6/socket.py in getaddrinfo(host, port, family, type, proto, flags)
    743     # and socket type values to enum constants.
    744     addrlist = []
--> 745     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
    746         af, socktype, proto, canonname, sa = res
    747         addrlist.append((_intenum_converter(af, AddressFamily),

gaierror: [Errno -3] Temporary failure in name resolution
VictorSanh commented 5 years ago

Ok, so it's definitely not coming from the gethostname() call. I am not sure but it seems that yagmail (the sublib that actually send the mail) can't access the gmail address you gave. Did you turn on less secure apps on this adress? Can you try with another integration (I believe the Telegram one is the fastest/easiest to setup) to check if you have the same issue with other channel?

mikelkl commented 5 years ago

@VictorSanh I tried slack_sender with success, thanks for your reply.