Author: Matti Picus <[email protected]>
Branch: cffi-libs
Changeset: r96652:39c032729bb6
Date: 2019-05-21 08:35 +0300
http://bitbucket.org/pypy/pypy/changeset/39c032729bb6/

Log:    nicer cleanup on failure in background thread function

diff --git a/lib-python/2.7/test/test_ftplib.py 
b/lib-python/2.7/test/test_ftplib.py
--- a/lib-python/2.7/test/test_ftplib.py
+++ b/lib-python/2.7/test/test_ftplib.py
@@ -234,11 +234,17 @@
     def run(self):
         self.active = True
         self.__flag.set()
-        while self.active and asyncore.socket_map:
-            self.active_lock.acquire()
-            asyncore.loop(timeout=0.1, count=1)
-            self.active_lock.release()
-        asyncore.close_all(ignore_all=True)
+        try:
+            while self.active and asyncore.socket_map:
+                self.active_lock.acquire()
+                try:
+                    asyncore.loop(timeout=0.1, count=1)
+                except:
+                    self.active_lock.release()
+                    raise
+                self.active_lock.release()
+        finally:
+            asyncore.close_all(ignore_all=True)
 
     def stop(self):
         assert self.active
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to