Closed mike-matera closed 1 year ago
To anyone reading this! Don't suffer like I did. This library supports FDs if you change the code to this:
bus = await MessageBus(bus_type=dbus_next.constants.BusType.SYSTEM, negotiate_unix_fd=True).connect()
@mike-matera Firstly, thank you for posting this. I was wondering why my code was hanging and had traced it to the client not supporting file descriptors which, in turn, led me here.
I'm looking to implement exactly the same think (i.e. a sleep inhibitor) but, for some reason, python isn't closing the file descriptor that's returned by the call to Inhibit
. I can call os.close
on it without error but the inhibitor isn't removed.
Do you have some fuller code that shows how you did it? Appreciate that this is almost 6 months after you posted this but thought I'd ask!
EDIT: I may have an idea as to my issue. I'm using the low-level interface and I was reading the spec and I see that the value returned by the inhibit call is the index to the relevant FD in the array of FDs that is passed with the message. I had just done a shortcut and taken the first FD in the array as I had just been getting one FD. I guess I'm getting more now!
Though the documentation states that FDs are in the type system the following code fails with a hang: