mercurial/httpclient/socketutil.py
changeset 25660 328739ea70c3
parent 19748 59df9e52b5bb
child 27601 1ad9da968a2e
equal deleted inserted replaced
25659:d60678a567a9 25660:328739ea70c3
    62             af, socktype, proto, unused_canonname, sa = res
    62             af, socktype, proto, unused_canonname, sa = res
    63             try:
    63             try:
    64                 sock = socket.socket(af, socktype, proto)
    64                 sock = socket.socket(af, socktype, proto)
    65                 logger.info("connect: (%s, %s)", host, port)
    65                 logger.info("connect: (%s, %s)", host, port)
    66                 sock.connect(sa)
    66                 sock.connect(sa)
    67             except socket.error, msg:
    67             except socket.error as msg:
    68                 logger.info('connect fail: %s %s', host, port)
    68                 logger.info('connect fail: %s %s', host, port)
    69                 if sock:
    69                 if sock:
    70                     sock.close()
    70                     sock.close()
    71                 sock = None
    71                 sock = None
    72                 continue
    72                 continue
    98                     "non-zero flags not allowed in calls to recv() on %s" %
    98                     "non-zero flags not allowed in calls to recv() on %s" %
    99                     self.__class__)
    99                     self.__class__)
   100             while True:
   100             while True:
   101                 try:
   101                 try:
   102                     return self._ssl.read(buflen)
   102                     return self._ssl.read(buflen)
   103                 except socket.sslerror, x:
   103                 except socket.sslerror as x:
   104                     if x.args[0] == socket.SSL_ERROR_WANT_READ:
   104                     if x.args[0] == socket.SSL_ERROR_WANT_READ:
   105                         continue
   105                         continue
   106                     else:
   106                     else:
   107                         raise x
   107                         raise x
   108 
   108