[pygobject/benzea/gio-asyncio] test




commit 8af4af1e8144b4e1fe609944f0cde119027371aa
Author: Benjamin Berg <bberg redhat com>
Date:   Wed Nov 17 15:48:18 2021 +0100

    test

 gi/events.py         | 16 ++++++++++++++++
 tests/test_events.py |  8 ++++++++
 2 files changed, 24 insertions(+)
---
diff --git a/gi/events.py b/gi/events.py
index 189a687b..3f2f57a6 100644
--- a/gi/events.py
+++ b/gi/events.py
@@ -122,9 +122,23 @@ class GLibEventLoop(asyncio.SelectorEventLoop):
         self._main_loop.quit()
 
     def close(self):
+        print("closing", self)
         super().close()
         for s in list(self.__signal_handlers):
             self.remove_signal_handler(s)
+        print("closed", self)
+
+    def __del__(self, _warn=warnings.warn):
+        super().__del__(_warn)
+        if not self.is_closed():
+            import traceback
+            traceback.print_stack
+
+    def __repr__(self):
+        return (
+            f'<{self.__class__.__name__} running={self.is_running()} '
+            f'closed={self.is_closed()} debug={self.get_debug()}>' + str(hash(self))
+        )
 
     if sys.platform != "win32":
         def add_signal_handler(self, sig, callback, *args):
@@ -393,8 +407,10 @@ class _Selector(selectors.BaseSelector):
         self._source.attach(loop._context)
 
     def close(self):
+        print("closing", self)
         self._source.destroy()
         super().close()
+        print("closed")
 
     def register(self, fileobj, events, data=None):
         if (not events) or (events & ~(selectors.EVENT_READ | selectors.EVENT_WRITE)):
diff --git a/tests/test_events.py b/tests/test_events.py
index 8fc4de4d..470f1ebb 100644
--- a/tests/test_events.py
+++ b/tests/test_events.py
@@ -63,6 +63,14 @@ if sys.platform != 'win32':
 
                     self.assertEqual(warns, [])
 
+        def test_popen_error_with_stdin_pipe(self):
+            # Issue #35721: check that newly created socket pair is closed when
+            # Popen fails
+            import subprocess
+            print(self.loop)
+            self.loop.run_until_complete(
+                self._test_popen_error(stdin=subprocess.PIPE))
+
         def setUp(self):
             super().setUp()
             policy = gi.events.GLibEventLoopPolicy()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]