-
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
Split responsibilities to Mode, Method, activate() and activate_using() (v. 0.8.0) #69
Comments
I wrote some initial ideas in #75 about renaming ModeActivator to ModeActivationProcess and splitting the responsibilities in three: MethodSelector, MethodPrioritizer and ModeActivator. I could try to implement the classes next. Modifying the list above to reflect the changes. |
As mentioned in #100, wakepy Mode activation process will be a blocking operation. This makes it possible to do everything, except heartbeat, in the main thread, which in turn makes things a lot easier. I've already written some documentation to the 0.8.0dev ("main") docs about how this all will work. The plan is roughly:
Rough implementation of activate(): def activate(methods: list[MethodCls], ...) -> tuple[ActivationResult, HeartBeat|None]:
prioritized_methods = prioritize_methods(methods)
result = ActivationResult()
for method in prioritized_methods:
methodresult, heartbeat = activate_using(method, ...)
result.add(methodresult)
if result.success:
break
return result, heartbeat
Rough implementation of activate_using() (pseudocode): def activate_using(methodcls: MethodCls, ...) -> tuple[MethodUsageResult, HeartBeat|None]:
method = methodcls()
if check_platform_support(method) is False:
return MethodUsageResult(failure_stage=PLATFORM_SUPPORT), None
if check_requirements(method) is False:
return MethodUsageResult(failure_stage=REQUIREMENTS), None
entered = try_enter_mode(method)
heartbeat_started = try_heartbeat(method)
if not entered or not heartbeat_started:
return MethodUsageResult(failure_stage=ACTIVATION), None
if heartbeat_started:
heartbeat = Heartbeat(method)
heartbeat.start()
return MethodUsageResult(), heartbeat
New Tasks
|
The rest of the work on this ticket has been split into multiple tickets. This one is done and can be closed. |
This is basically a ticket to myself, and is continuation of work in the PR #51, which left the main branch in an unfinished and bit messy state.
Modes
Mode.__exit__
and addModeExit
exception which can be used to exit the mode with statement block. (PR #72)Mode
(for supporting running wakepy in multiple threads) (PR #71)Deprecated
work done on this ticket but not relevant anymore
using the queues.
The text was updated successfully, but these errors were encountered: