GLib.IOChannel.read blocks forever in GLib 2.64
Recently I upgraded to GLib 2.64 and watching
/dev/rfkill with an IOChannel broke. Below is a minimal example that shows the problem. The example below works perfectly fine under GLib 2.62. What appears to resolve out problem is explicitly setting the encoding to None.
I am posting it here as he could not replicate the block in c so our guess is that it is something in gi/pygobject.
from gi.repository import GLib def tick(): print("Alive") return True def on_event(channel, condition): data = channel.read(8) print(data) channel = GLib.IOChannel.new_file("/dev/rfkill", "r") # channel.set_encoding(None) ## uncomment to make it work wid = GLib.io_add_watch(channel, GLib.IO_IN | GLib.IO_ERR | GLib.IO_HUP, on_event) GLib.timeout_add_seconds(1, tick) loop = GLib.MainLoop() loop.run()