asyncio-glib icon indicating copy to clipboard operation
asyncio-glib copied to clipboard

glib_selector: Only ever iterate the mainloop once

Open benzea opened this issue 5 years ago • 1 comments

As it is right now, any python code that runs may modify the timeout that would be passed into the select() call. As such, we can only run a single mainloop iteration before the select() call needs to be restarted.

Also, we cannot use g_source_set_ready_time, because GLib will always do a full mainloop iteration afterwards to ensure that all sources had a chance to dispatch. This is easy to work around though as we can use the prepare callback to pass the required timeout from python into the GLib main loop code.

Note that with this we end up iterating the main context but we never actually run a GLib mainloop.

Fixes: #3

benzea avatar Nov 08 '20 17:11 benzea

I think this is a much better approach to fix this than #4, #7 and #8 are. No need to override more methods on the python side and I think it is reasonable to return to python after every GLib mainloop iteration.

Really, conceptually we just run a GMainContext using the python mainloop (in a somewhat backward way, but it is reasonable).

benzea avatar Nov 08 '20 17:11 benzea