You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
but that raises questions like: What does "success" mean here is the flag is set and the mode is not entered?
It would be probably enough to document a recipe for conditionally using a wakepy mode using the solution from the standard library: nullcontext -- which conveniently supports Python 3.7+ (all versions which wakepy supports). The recipe is:
because the with statement target (m) does will be a Mode instance when using keep.running() and None by default when using the nullcontext. As the nullcontext gives any input argument as the with statement target, there it could be:
This already needs two imports and requires that the user knows about the contextlib.nullcontext. It would be probably more user-friendly to provide the dummy / no-op mode from wakepy, so one could write:
It's probably quite usual use case to do something like:
I thought first that there could be some conditional flag added to the modes, like
but that raises questions like: What does "success" mean here is the flag is set and the mode is not entered?
It would be probably enough to document a recipe for conditionally using a wakepy mode using the solution from the standard library: nullcontext -- which conveniently supports Python 3.7+ (all versions which wakepy supports). The recipe is:
EDIT: The nullcontext is not a 100% drop-in replacement as you cannot do, for example:
because the with statement target (
m
) does will be a Mode instance when usingkeep.running()
and None by default when using thenullcontext
. As thenullcontext
gives any input argument as the with statement target, there it could be:This already needs two imports and requires that the user knows about the
contextlib.nullcontext
. It would be probably more user-friendly to provide the dummy / no-op mode from wakepy, so one could write:Questions to be answered:
1. What is the nicest name for this?
DummyMode
-> usage:DummyMode()
dummy_mode
-> usage:dummy_mode()
(function)dummy_mode
-> usage:dummy_mode
(instance of Mode. Does nothing. Reusable)dummy
ordummy()
ordummymode
ordummymode()
noop
: usage:noop()
ornoop
noop_mode
/noop_mode()
2. What attributes/attribute values the DummyMode should have?
From the docs, the Modes have the following attributes (among others):
3. Is this any better than using
keep.running(only_if=some_flag)
?This is starting to become more complicated. Would the initial idea be simper from the user's perspective?
Task
Comments / suggestions welcome!
The text was updated successfully, but these errors were encountered: