File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 15
15
class GLibEventLoop (asyncio .SelectorEventLoop ):
16
16
"""An asyncio event loop that runs the GLib main loop"""
17
17
18
- def __init__ (self , main_context = None ):
18
+ def __init__ (self , main_context = None , handle_sigint = False ):
19
19
if main_context is None :
20
20
main_context = GLib .MainContext .default ()
21
- selector = glib_selector .GLibSelector (main_context )
21
+ selector = glib_selector .GLibSelector (main_context , handle_sigint )
22
22
self .selector = selector
23
23
super ().__init__ (selector )
24
24
Original file line number Diff line number Diff line change @@ -67,10 +67,15 @@ def clear(self):
67
67
68
68
class GLibSelector (selectors ._BaseSelectorImpl ):
69
69
70
- def __init__ (self , context ):
70
+ def __init__ (self , context , handle_sigint = False ):
71
71
super ().__init__ ()
72
72
self ._context = context
73
- self ._main_loop = GLib .MainLoop .new (self ._context , False )
73
+ if handle_sigint :
74
+ self ._main_loop = GLib .MainLoop ()
75
+ self ._run = GLib .MainLoop .run
76
+ else :
77
+ self ._main_loop = GLib .MainLoop .new (self ._context , False )
78
+ self ._run = g_main_loop_run
74
79
self ._source = _SelectorSource (self ._main_loop )
75
80
self ._source .attach (self ._context )
76
81
@@ -100,7 +105,7 @@ def select(self, timeout=None):
100
105
101
106
self ._source .clear ()
102
107
if may_block :
103
- g_main_loop_run (self ._main_loop )
108
+ self . _run (self ._main_loop )
104
109
else :
105
110
self ._context .iteration (False )
106
111
You can’t perform that action at this time.
0 commit comments