Skip to content

Commit 5c44397

Browse files
committed
Clarify the use of manual socket io ref control in UDP transport
1 parent 2952077 commit 5c44397

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

uvloop/handles/udp.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ cdef class UDPTransport(UVBaseTransport):
1010
cdef _init(self, Loop loop, object sock, object r_addr):
1111
self._start_init(loop)
1212
try:
13+
# It's important to incref the socket in case it
14+
# was created outside of uvloop,
15+
# i.e. `look.create_datagram_endpoint(sock=sock)`.
1316
socket_inc_io_ref(sock)
17+
1418
self.sock = sock
1519
self.address = r_addr
1620
self.poll = UVPoll.new(loop, sock.fileno())

0 commit comments

Comments
 (0)