From 237c47fb261bda74a600f05ca19f5c780e30b479 Mon Sep 17 00:00:00 2001
From: Jason Madden <jamadden@gmail.com>
Date: Wed, 16 Dec 2020 17:09:35 -0600
Subject: [PATCH] Semaphore: Dont try to notify if the links have vanished.

---
 src/gevent/_abstract_linkable.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/gevent/_abstract_linkable.py b/src/gevent/_abstract_linkable.py
index 5f7ccd13..5444db55 100644
--- a/src/gevent/_abstract_linkable.py
+++ b/src/gevent/_abstract_linkable.py
@@ -223,6 +223,12 @@ class AbstractLinkable(object):
         # links in order. Lets the ``links`` list be mutated,
         # and only notifies up to the last item in the list, in case
         # objects are added to it.
+        if not links:
+            # HMM. How did we get here? Running two threads at once?
+            # Seen once on Py27/Win/Appveyor
+            # https://ci.appveyor.com/project/jamadden/gevent/builds/36875645/job/9wahj9ft4h4qa170
+            return []
+
         only_while_ready = not self._notify_all
         final_link = links[-1]
         done = set() # of ids
-- 
2.30.9