charmhelpers.core.reactive.helpers¶
any_file_changed |
Check if any of the given files have changed since the last time this was called. |
data_changed |
Check if the given set of data has changed since the previous call. |
mark_invoked |
Mark the given ID as having been invoked, for use with was_invoked(). |
was_invoked |
Returns whether the given ID has been invoked before, as per mark_invoked(). |
-
charmhelpers.core.reactive.helpers.any_file_changed(filenames, hash_type='md5')¶ Check if any of the given files have changed since the last time this was called.
Parameters: - filenames (list) – Names of files to check.
- hash_type (str) – Algorithm to use to check the files.
-
charmhelpers.core.reactive.helpers.data_changed(data_id, data, hash_type='md5')¶ Check if the given set of data has changed since the previous call.
This works by hashing the JSON-serialization of the data. Note that, while the data will be serialized using
sort_keys=True, some types of data structures, such as sets, may lead to false positivies.Parameters: - data_id (str) – Unique identifier for this set of data.
- data – JSON-serializable data.
- hash_type (str) – Any hash algorithm supported by
hashlib.
-
charmhelpers.core.reactive.helpers.mark_invoked(invocation_id)¶ Mark the given ID as having been invoked, for use with
was_invoked().
-
charmhelpers.core.reactive.helpers.was_invoked(invocation_id)¶ Returns whether the given ID has been invoked before, as per
mark_invoked().This is useful for ensuring that a given block only runs one time:
def foo(): if was_invoked('foo'): return do_something() mark_invoked('foo')
This is also available as a decorator at
only_once().