-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it possible to select what happens with errors #29
Comments
Working on this and planning to include in the next release. |
This should be done now, and available in the dev branch. Will merge to master and publish a version in PyPI once tests and docs are also ready. Edit: Changed branch name to |
Nice work. Will include that in Minarca Data Backup whenever you make the release. Did you also check if the exception is properly raised by Thanks |
Thanks for commenting! Yeah I had some nice Easter holidays writing an update :) It is definitely a goal to remove all exceptions for any errors occuring at import time ( e.g. when doing |
Ok great !
Agree with you. You should focus only on |
This is now fixed in a released version 0.7.1. The new syntax is from wakepy import keep
with keep.running() as m:
if not m.success:
# optional: signal to user?
do_something() The idea is that you may now decide to signal to the user somehow if the inhibitor lock could not be taken; this can be checked with The |
Reopening this. I think the 0.7.1 implementation had in mind that entering the context manager might be a non-blocking call. Since it will be a blocking call in the future, I think that an input argument |
Planning to make the following changes. The modes will have with keep.running(on_fail="warn"):
... The on fail can either a string or a callable.
The ActivationResult has more information about the activation process, and can later be extended if needed. The default of "error" comes from zen of python:
There are two types of use cases for wakepy
|
The current implementation simply raises
NotImplementedError
on linux if none of the existing methods (jeepney, dbus-python, systemd) can be used. It would be nicer for the user to be able to control what happens if using keepawake is not possible.Currently, if someone would like to continue when setting keepawake is not possible, something like this must be used:
Option A
Option B
Idea
It would be nicer if the user could decide what occurs when:
(a) A keepawake method fails (dbus address not found, etc..) -->
on_method_failure
(b) Setting keepawake fails completely -->
on_failure
Then, code could look something like this:
This is much cleaner code and nicer to the user. Suggested options for
on_failure
andon_method_failure
could beSo, on linux, with multiple methods defined:
keepawake(method_linux=('jeepney', 'systemd')):
would, in absense of dbus address and sudo rights, by default:logger.info
logger.info
KeepAwakeError
and tell that jeepney cannot be used becauseDBUS_SESSION_BUS_ADDRESS
is not set and systemd cannot be used because sudo rights are missing.The text was updated successfully, but these errors were encountered: