@@ -1861,28 +1861,23 @@ cdef class Loop:
18611861 self ._add_reader(fd, handle)
18621862 return fut
18631863
1864- def sock_connect (self , sock , address ):
1864+ async def sock_connect(self , sock, address):
18651865 """ Connect to a remote socket at address.
18661866
1867- The address must be already resolved to avoid the trap of hanging the
1868- entire event loop when the address requires doing a DNS lookup. For
1869- example, it must be an IP address, not a hostname, for AF_INET and
1870- AF_INET6 address families. Use getaddrinfo() to resolve the hostname
1871- asynchronously.
1872-
18731867 This method is a coroutine.
18741868 """
18751869 if self ._debug and sock.gettimeout() != 0 :
18761870 raise ValueError (" the socket must be non-blocking" )
1871+
18771872 fut = self ._new_future()
1878- try :
1879- if self ._debug:
1880- aio__check_resolved_address(sock, address)
1881- except ValueError as err:
1882- fut.set_exception(err)
1883- else :
1873+ if sock.family == uv.AF_UNIX:
18841874 self ._sock_connect(fut, sock, address)
1885- return fut
1875+ await fut
1876+ return
1877+
1878+ _, _, _, _, address = (await self .getaddrinfo(* address))[0 ]
1879+ self ._sock_connect(fut, sock, address)
1880+ await fut
18861881
18871882 def run_in_executor (self , executor , func , *args ):
18881883 if aio_iscoroutine(func) or aio_iscoroutinefunction(func):
0 commit comments