[pygobject/benzea/gio-asyncio] Prefix with glib



commit bad2b897f358790c148b51f01d2307e5ba3338cb
Author: Benjamin Berg <bberg redhat com>
Date:   Wed Nov 17 15:47:54 2021 +0100

    Prefix with glib

 gi/events.py         | 16 ++++++++--------
 tests/test_events.py | 10 +++++-----
 2 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/gi/events.py b/gi/events.py
index f9df3a05..0226be1b 100644
--- a/gi/events.py
+++ b/gi/events.py
@@ -18,7 +18,7 @@
 # You should have received a copy of the GNU Lesser General Public
 # License along with this library; if not, see <http://www.gnu.org/licenses/>.
 
-__all__ = ['EventLoopPolicy', 'EventLoop']
+__all__ = ['GLibEventLoopPolicy', 'GLibEventLoop']
 
 import sys
 import asyncio
@@ -38,7 +38,7 @@ except AttributeError:
     g_main_loop_run = GLib.MainLoop.run
 
 
-class EventLoop(asyncio.SelectorEventLoop):
+class GLibEventLoop(asyncio.SelectorEventLoop):
     """An asyncio event loop that runs the python mainloop inside GLib.
 
     Based on the asyncio.SelectorEventLoop"""
@@ -185,7 +185,7 @@ class EventLoop(asyncio.SelectorEventLoop):
             self.call_soon(cb, *args)
 
 
-class EventLoopPolicy(events.AbstractEventLoopPolicy):
+class GLibEventLoopPolicy(events.AbstractEventLoopPolicy):
     """An asyncio event loop policy that runs the GLib main loop.
 
     The policy allows creating a new EventLoop for threads other than the main
@@ -217,7 +217,7 @@ class EventLoopPolicy(events.AbstractEventLoopPolicy):
         main context and main loop which can subsequently attached to the thread
         by calling set_event_loop().
 
-        Returns a new EventLoop or raises an exception."""
+        Returns a new GLibEventLoop or raises an exception."""
         # Get the thread default main context
         ctx = GLib.MainContext.get_thread_default()
         # If there is none, and we are on the main thread, then use the default context
@@ -238,7 +238,7 @@ class EventLoopPolicy(events.AbstractEventLoopPolicy):
         except KeyError:
             pass
 
-        self._loops[ctx] = EventLoop(ctx)
+        self._loops[ctx] = GLibEventLoop(ctx)
         if self._child_watcher and ctx == GLib.MainContext.default():
             self._child_watcher.attach_loop(self.get_event_loop())
         return self._loops[ctx]
@@ -251,7 +251,7 @@ class EventLoopPolicy(events.AbstractEventLoopPolicy):
         """
 
         # Only accept glib event loops, otherwise things will just mess up
-        assert loop is None or isinstance(loop, EventLoop)
+        assert loop is None or isinstance(loop, GLibEventLoop)
 
         # Refuse operating on the main thread. Technically we could allow it,
         # but I can't think of a use-case and doing it is dangerous.
@@ -279,7 +279,7 @@ class EventLoopPolicy(events.AbstractEventLoopPolicy):
         """Create and return a new event loop that iterates a new
         GLib.MainContext."""
 
-        return EventLoop(GLib.MainContext())
+        return GLibEventLoop(GLib.MainContext())
 
     # NOTE: We do *not* provide a GLib based ChildWatcher implementation!
     # This is *intentional* and *required*. The issue is that python provides
@@ -375,7 +375,7 @@ class _SelectorKey(selectors.SelectorKey):
 
 
 class _Selector(selectors.BaseSelector):
-    """A Selector for gi.asyncio.EventLoop registering python IO with GLib."""
+    """A Selector for gi.events.GLibEventLoop registering python IO with GLib."""
 
     def __init__(self, context, loop):
         super().__init__()
diff --git a/tests/test_events.py b/tests/test_events.py
index 07a7f967..8fc4de4d 100644
--- a/tests/test_events.py
+++ b/tests/test_events.py
@@ -33,7 +33,7 @@ if sys.platform != 'win32':
     class GLibEventLoopTests(UnixEventLoopTestsMixin, test_utils.TestCase):
 
         def create_event_loop(self):
-            return gi.events.EventLoop(main_context=GLib.MainContext.default())
+            return gi.events.GLibEventLoop(main_context=GLib.MainContext.default())
 
     class SubprocessWatcherTests(SubprocessMixin, test_utils.TestCase):
 
@@ -65,7 +65,7 @@ if sys.platform != 'win32':
 
         def setUp(self):
             super().setUp()
-            policy = gi.events.EventLoopPolicy()
+            policy = gi.events.GLibEventLoopPolicy()
             asyncio.set_event_loop_policy(policy)
             self.loop = policy.get_event_loop()
 
@@ -77,19 +77,19 @@ if sys.platform != 'win32':
 class GLibEventLoopPolicyTests(unittest.TestCase):
 
     def create_policy(self):
-        return gi.events.EventLoopPolicy()
+        return gi.events.GLibEventLoopPolicy()
 
     def test_get_event_loop(self):
         policy = self.create_policy()
         loop = policy.get_event_loop()
-        self.assertIsInstance(loop, gi.events.EventLoop)
+        self.assertIsInstance(loop, gi.events.GLibEventLoop)
         self.assertIs(loop, policy.get_event_loop())
         loop.close()
 
     def test_new_event_loop(self):
         policy = self.create_policy()
         loop = policy.new_event_loop()
-        self.assertIsInstance(loop, gi.events.EventLoop)
+        self.assertIsInstance(loop, gi.events.GLibEventLoop)
         loop.close()
 
         # Attaching a loop to the main thread fails


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