From 0360dab08c169af507680a510d65537019045a05 Mon Sep 17 00:00:00 2001 From: Fantix King Date: Mon, 8 Feb 2021 16:07:04 -0500 Subject: [PATCH] Fix future issue in sock_connect() CPython fixed the same issue in python/cpython#10419. Seems like under pressure, more write callbacks may happen before _remove_writer() is called, so we should check for done(). Fixes #378 --- uvloop/loop.pyx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/uvloop/loop.pyx b/uvloop/loop.pyx index 9ebf3a63..3ebc6588 100644 --- a/uvloop/loop.pyx +++ b/uvloop/loop.pyx @@ -1059,7 +1059,8 @@ cdef class Loop: return fut cdef _sock_connect_cb(self, fut, sock, address): - if fut.cancelled(): + if fut.done(): + # Refs #378: this may be called multiple times. return try: