[pygobject/benzea/gio-asyncio: 2/2] fixup! events: Implement asyncio event loop based on glib
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/benzea/gio-asyncio: 2/2] fixup! events: Implement asyncio event loop based on glib
- Date: Fri, 19 Nov 2021 16:10:06 +0000 (UTC)
commit d75e9aa9fe507c3a19792b096f59e887a42a3f41
Author: Benjamin Berg <bberg redhat com>
Date: Fri Nov 19 17:09:58 2021 +0100
fixup! events: Implement asyncio event loop based on glib
gi/events.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/gi/events.py b/gi/events.py
index 5404d2bd..d713893f 100644
--- a/gi/events.py
+++ b/gi/events.py
@@ -258,7 +258,7 @@ class GLibEventLoopPolicy(events.AbstractEventLoopPolicy):
# the pointer to the C structure.
print(f"ctx=0x{hash(self._context):X}")
try:
- loop = self._loops[ctx]
+ loop = self._loops[hash(ctx)]
if not loop.is_closed():
print(f"got existing loop {loop}")
return loop
@@ -267,11 +267,11 @@ class GLibEventLoopPolicy(events.AbstractEventLoopPolicy):
print("no loop for context")
pass
- self._loops[ctx] = GLibEventLoop(ctx)
- print(f"got new loop {self._loops[ctx]}")
+ self._loops[hash(ctx)] = GLibEventLoop(ctx)
+ print(f"got new loop {self._loops[hash(ctx)]}")
if self._child_watcher and ctx == GLib.MainContext.default():
self._child_watcher.attach_loop(self.get_event_loop())
- return self._loops[ctx]
+ return self._loops[hash(ctx)]
def set_event_loop(self, loop):
"""Set the event loop for the current context (python thread) to loop.
@@ -301,7 +301,7 @@ class GLibEventLoopPolicy(events.AbstractEventLoopPolicy):
% threading.current_thread().name)
GLib.MainContext.push_thread_default(loop._context)
- self._loops[loop._context] = loop
+ self._loops[hash(loop._context)] = loop
def new_event_loop(self):
"""Create and return a new event loop that iterates a new
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]