class JSONRegistry(Generic[
A JSONRegistry
maintains a set of functions and methods (and the classes those methods are defined on) that can scheduled against a Scheduler
and then persisted into a JSON blob to reconstitute that scheduler later.
Use a JSONRegistry
by instantiatint it at module scope and then using its methods as decorators on functions and methods.
Method | create |
Create a new JSONableScheduler with the same type as if it had been loaded by this JSONRegistry . |
Method | function |
Mark the given 0-argument, None-returning, top-level function as possible to serialize within this registry. It will be serialized by its fully-qualified Python name. |
Method | load |
Load a JSON object in the format serialized by the saver returned by JSONRegistry.createScheduler (or this method) and a runtime TimeDriver [DateTime[ZoneInfo]], returning a 2-tuple of JSONableScheduler ... |
Method | method |
Mark the given method, defined at class scope in a class complying with the JSONableInstance protocol, as possible to serialize within this registry. |
Method | repeatedly |
Call work repeatedly, according to rule, with intervals computed according to the given reference time (or scheduler's current time, if not given). |
Method | repeat |
Mark the given function that matches the signature of RepeatingWork , i.e. one which takes a number of steps and a Cancellable to cancel its own repetition, as looked up via its __qualname__ attribute. |
Method | repeat |
Mark the given method that matches the signature of RepeatingWork , i.e. one which takes a number of steps and a Cancellable to cancel its own repetition, as looked up via its __qualname__ attribute. |
Method | save |
Convert a ScheduledCall into a JSON-serializable object. |
Method | _load |
Convert the given JSON-dumpable dict into an object of _JSONableType via its JSONableInstance.fromJSON classmethod registered in the given _SpecificTypeRegistration . |
Method | _load |
Undocumented |
Method | _register |
Mark the given class as serializable via this registry, keyed by its JSONable.typeCodeForJSON method. Used internally as supporting JSONRegistry.method and JSONRegistry.repeatMethod . |
Method | _register |
Undocumented |
Method | _repeater |
Convert the given JSONRepeater into a method that can be serialized. |
Method | _saver |
Undocumented |
Method | _save |
Undocumented |
Class Variable | _functions |
Undocumented |
Class Variable | _instances |
Undocumented |
Class Variable | _repeatable |
Undocumented |
Class Variable | _rules |
Undocumented |
Class Variable | _ruletype2jsonifier |
Undocumented |
TimeDriver[ DTZI]
) -> tuple[ JSONableScheduler[ BootstrapT], Callable[ [], JSONObject]]
:
(source)
¶
Create a new JSONableScheduler
with the same type as if it had been loaded by this JSONRegistry
.
Mark the given 0-argument, None-returning, top-level function as possible to serialize within this registry. It will be serialized by its fully-qualified Python name.
Use like so:
registry = JSONRegistry[...]() @registry.serializedFunction
TimeDriver[ DTZI]
, serializedJSON: JSONObject
, bootstrap: BootstrapT
) -> tuple[ JSONableScheduler[ BootstrapT], Callable[ [], JSONObject]]
:
(source)
¶
Load a JSON object in the format serialized by the saver returned by JSONRegistry.createScheduler
(or this method) and a runtime TimeDriver
[DateTime[ZoneInfo]], returning a 2-tuple of JSONableScheduler
and a 0-argument callable which will serialize the current contents of that scheduler.
Callable[ [ JSONableSelf], None]
) -> JSONableMethodDescriptor[ JSONableSelf, BootstrapT]
:
(source)
¶
Mark the given method, defined at class scope in a class complying with the JSONableInstance
protocol, as possible to serialize within this registry.
JSONableScheduler[ BootstrapT]
, rule: RecurrenceRule[ DTZI, StepsT]
, work: JSONableRepeatable[ BootstrapT, StepsT]
, reference: DTZI|None
= None):
(source)
¶
Call work repeatedly, according to rule, with intervals computed according to the given reference time (or scheduler's current time, if not given).
If you want to stop the repetition, work is passed a Cancellable
that you can call .cancel() on to do so.
See Also | |
fritter.repeat |
RepeatingWork[ StepsT]
) -> JSONableRepeatable[ BootstrapT, StepsT]
:
(source)
¶
Mark the given function that matches the signature of RepeatingWork
, i.e. one which takes a number of steps and a Cancellable
to cancel its own repetition, as looked up via its __qualname__ attribute.
Returns | |
JSONableRepeatable[ | a function that mimics the signature of the original function, but also conforms to the JSONable protocol. |
_Repeater[ JSONableSelf, StepsT]
) -> JSONableRepeatableDescriptor[ JSONableSelf, BootstrapT, StepsT]
:
(source)
¶
Mark the given method that matches the signature of RepeatingWork
, i.e. one which takes a number of steps and a Cancellable
to cancel its own repetition, as looked up via its __qualname__ attribute.
Returns | |
JSONableRepeatableDescriptor[ | a descriptor that mimics the signature of the original method. |
Note | |
The registration occurs when the class is defined, specifically in the __set_name__ hook in the returned descriptor, so if you are calling this in an esoteric context outside a normal class definition, be sure to invoke that hook as well. |
JSONObject
, which: _SpecificTypeRegistration[ _JSONableCallableT]
, load: LoadProcess[ BootstrapT]
) -> _JSONableCallableT
:
(source)
¶
Convert the given JSON-dumpable dict into an object of _JSONableType via its JSONableInstance.fromJSON
classmethod registered in the given _SpecificTypeRegistration
.
Mark the given class as serializable via this registry, keyed by its JSONable.typeCodeForJSON
method. Used internally as supporting JSONRegistry.method
and JSONRegistry.repeatMethod
.
JSONRepeater[ BootstrapT, StepsT]
) -> JSONableBoundMethod[ _JSONableRepeaterWrapper[ BootstrapT, StepsT]]
:
(source)
¶
Convert the given JSONRepeater
into a method that can be serialized.
Heap[ Any]
, s: JSONableScheduler[ BootstrapT]
) -> Callable[ [], JSONObject]
:
(source)
¶
Undocumented
dict[ type[ RecurrenceRule[ DTZI, object]], RuleJSONIfier[ RecurrenceRule[ DTZI, Any]]]
=
(source)
¶
Undocumented