Venom1991 / refind-btrfs

Generate rEFInd manual boot stanzas from Btrfs snapshots
GNU General Public License v3.0
144 stars 8 forks source link

Running with "--run-mode background" arguments leads to "TypeError: BaseObserver.dispatch_events() takes 2 positional arguments but 3 were given" #42

Closed rizzini closed 1 year ago

rizzini commented 1 year ago

--run-mode one-time works fine. I'm on Gentoo. I tested with Python 3.9 an 3.10.

Edit: I guess I can schedule the "one time" some other way, but I'm trying to keep scheduled stuff organized with systemd. Anyway, that error is odd. Probably something on my environment.

Systemd service status(on the terminal, it crashes with no output whatsoever): Python 3.10:

× refind-btrfs.service - Generate rEFInd manual boot stanzas from Btrfs snapshots
     Loaded: loaded (/etc/systemd/system/refind-btrfs.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Tue 2022-10-11 23:11:57 -03; 2min 34s ago
   Duration: 58ms
    Process: 104802 ExecStart=/usr/bin/refind-btrfs --run-mode background (code=exited, status=1/FAILURE)
   Main PID: 104802 (code=exited, status=1/FAILURE)
      Error: 1 (Operação não permitida)

out 11 23:11:57 gentoo systemd[1]: Starting Generate rEFInd manual boot stanzas from Btrfs snapshots...
out 11 23:11:57 gentoo /usr/bin/refind-btrfs[104802]: Scheduling watch for directories: /mnt/archlinux/btrbk_snapshots/GENTOO_ROOT.
out 11 23:11:57 gentoo /usr/bin/refind-btrfs[104802]: Starting the observer with PID 104802.
out 11 23:11:57 gentoo systemd[1]: Started Generate rEFInd manual boot stanzas from Btrfs snapshots.
out 11 23:11:57 gentoo /usr/bin/refind-btrfs[104802]: ERROR (refind_btrfs.service.snapshot_observer/snapshot_observer.py/run): An unexpected error happened, exiting...
                                                      Traceback (most recent call last):
                                                        File "/root/.local/lib/python3.10/site-packages/refind_btrfs/service/snapshot_observer.py", line 45, in run
                                                          self.dispatch_events(self.event_queue, self.timeout)
                                                      TypeError: BaseObserver.dispatch_events() takes 2 positional arguments but 3 were given
out 11 23:11:57 gentoo systemd[1]: refind-btrfs.service: Main process exited, code=exited, status=1/FAILURE
out 11 23:11:57 gentoo systemd[1]: refind-btrfs.service: Failed with result 'exit-code'.

3.9:

× refind-btrfs.service - Generate rEFInd manual boot stanzas from Btrfs snapshots
     Loaded: loaded (/etc/systemd/system/refind-btrfs.service; enabled; preset: disabled)
     Active: failed (Result: exit-code) since Wed 2022-10-12 00:09:15 -03; 1s ago
   Duration: 48ms
    Process: 224109 ExecStart=/usr/bin/python3.9 -m refind_btrfs --run-mode background (code=exited, status=1/FAILURE)
   Main PID: 224109 (code=exited, status=1/FAILURE)
      Error: 1 (Operação não permitida)

out 12 00:09:15 gentoo systemd[1]: Starting Generate rEFInd manual boot stanzas from Btrfs snapshots...
out 12 00:09:15 gentoo /usr/lib/python3.9/site-packages/refind_btrfs/__main__.py[224109]: Scheduling watch for directories: /mnt/archlinux/btrbk_snapshots/GENTOO_ROOT.
out 12 00:09:15 gentoo /usr/lib/python3.9/site-packages/refind_btrfs/__main__.py[224109]: Starting the observer with PID 224109.
out 12 00:09:15 gentoo systemd[1]: Started Generate rEFInd manual boot stanzas from Btrfs snapshots.
out 12 00:09:15 gentoo /usr/lib/python3.9/site-packages/refind_btrfs/__main__.py[224109]: ERROR (refind_btrfs.service.snapshot_observer/snapshot_observer.py/run): An unexpected>
                                                                                          Traceback (most recent call last):
                                                                                            File "/usr/lib/python3.9/site-packages/refind_btrfs/service/snapshot_observer.py", l>
                                                                                              self.dispatch_events(self.event_queue, self.timeout)
                                                                                          TypeError: dispatch_events() takes 2 positional arguments but 3 were given
out 12 00:09:15 gentoo systemd[1]: refind-btrfs.service: Main process exited, code=exited, status=1/FAILURE
out 12 00:09:15 gentoo systemd[1]: refind-btrfs.service: Failed with result 'exit-code'.
Venom1991 commented 1 year ago

Systemd service status(on the terminal, it crashes with no output whatsoever)

That's expected because, in this mode, all the output is directed towards the systemd's journal instead of the standard output.

This is a Pip installation, I guess?

I used to regularly upgrade Pip dependencies and also check them by debugging both modes of operation but I suppose that I forgot to debug the background mode during the last upgrade.

Watchdog authors removed one parameter about 10 months ago in this commit. Arch still uses a pretty old Watchdog's release branch in which that parameter still exists.
I've opened a relevant bug a long time ago but it's still unresolved.

Basically, this issue is caused by a library version mismatch between the AUR and Pip dependencies. I cannot amend the source code because that would break the AUR package, obviously. All that I can do is downgrade the Pip dependency but that's not currently possible because my Arch installation broke apart fairly recently and I still can't find the time to perform a fresh installation.
I could have downgraded it myself but, like I said, I forgot to debug it before pushing the new version to PyPI...

It's not a lot of work, perhaps you could give it a try?

I'm sorry for the late reply.

rizzini commented 1 year ago

Sorry for the delay.. For some reason, my Google Chrome Github extension that handle notifications wasn't working.

It's not a lot of work, perhaps you could give it a try?

I'd love to, but this is something over my head, since I don't know python at all. I can handle some simple troubleshooting, but it stops there. Sorry, man.. I really wish I could help.

Venom1991 commented 1 year ago

@rizzini

I somehow managed to downgrade the "watchdog" dependency on a Windows machine (what a pain). A new version has been pushed to PyPI. Try installing it and see if it fixed the issue.

rizzini commented 1 year ago

Are you still having issues with your Linux system? That I can help. Anyway, I'm getting the same msg about positional arguments. Exactly the same. It almost seems I didn't update, but I did. I was suspicious of something going wrong in the first time, so I did it twice.

Venom1991 commented 1 year ago

Are you still having issues with your Linux system?

Yep, still broken. I can't find the time for a fresh install.

My guess is that pip didn't downgrade the "watchdog" package after upgrading refind-btrfs. You could try running:

pip install --force-reinstall watchdog==2.1.6

or

pip install --upgrade watchdog==2.1.6

I checked the source code of that exact release and both parameters were present (I don't count "self" as a parameter).

rizzini commented 1 year ago

My guess is that pip didn't downgrade the "watchdog" package after upgrading refind-btrfs. You could try running:

Oh yeah.. That was it! It's working now. Keep it up, man. 🤘

Venom1991 commented 1 year ago

My guess is that pip didn't downgrade the "watchdog" package after upgrading refind-btrfs. You could try running:

Oh yeah.. That was it! It's working now. Keep it up, man. 🤘

Great, please close the issue if it's not too much to ask. 👍🏼

Venom1991 commented 1 year ago

I pinned all the dependencies' versions found in this file (only those which are required at runtime, of course). This is a bit ugly but it should be safe, especially in case refind-btrfs is the sole globally installed PyPI package.