Utilities¶
Warning
External usage of internal utility functions and modules should be kept to a minimum as they may be altered, refactored or moved to other locations without notice (and without the typical deprecation cycle).
Async¶
Deprecation¶
-
taskflow.utils.deprecation.
deprecation
(message, stacklevel=None)[source]¶ Warns about some type of deprecation that has been (or will be) made.
This helper function makes it easier to interact with the warnings module by standardizing the arguments that the warning function recieves so that it is easier to use.
This should be used to emit warnings to users (users can easily turn these warnings off/on, see https://docs.python.org/2/library/warnings.html as they see fit so that the messages do not fill up the users logs with warnings that they do not wish to see in production) about functions, methods, attributes or other code that is deprecated and will be removed in a future release (this is done using these warnings to avoid breaking existing users of those functions, methods, code; which a library should avoid doing by always giving at least N + 1 release for users to address the deprecation warnings).
-
class
taskflow.utils.deprecation.
MovedClassProxy
(wrapped, message, stacklevel)[source]¶ Bases:
object
Acts as a proxy to a class that was moved to another location.
Partially based on:
http://code.activestate.com/recipes/496741-object-proxying/ and other various examination of how to make a good enough proxy for our usage to move the various types we want to move during the deprecation process.
And partially based on the wrapt object proxy (which we should just use when it becomes available @ http://review.openstack.org/#/c/94754/).
-
taskflow.utils.deprecation.
moved_proxy_class
(new_class, old_class_name, old_module_name, message=None, version=None, removal_version=None, stacklevel=3)[source]¶ Deprecates a class that was moved to another location.
This will emit warnings when the old locations class is initialized, telling where the new and improved location for the old class now is.
Eventlet¶
Iterators¶
-
taskflow.utils.iter_utils.
fill
(it, *args, **kwargs)[source]¶ Iterates over a provided iterator up to the desired length.
If the source iterator does not have enough values then the filler value is yielded until the desired length is reached.
-
taskflow.utils.iter_utils.
count
(it, *args, **kwargs)[source]¶ Returns how many values in the iterator (depletes the iterator).
-
taskflow.utils.iter_utils.
generate_delays
(delay, max_delay, multiplier=2)[source]¶ Generator/iterator that provides back delays values.
The values it generates increments by a given multiple after each iteration (using the max delay as a upper bound). Negative values will never be generated... and it will iterate forever (ie it will never stop generating values).
-
taskflow.utils.iter_utils.
unique_seen
(its, seen_selector=None)[source]¶ Yields unique values from iterator(s) (and retains order).
-
taskflow.utils.iter_utils.
find_first_match
(it, *args, **kwargs)[source]¶ Searches iterator for first value that matcher callback returns true.
Kazoo¶
Kombu¶
-
class
taskflow.utils.kombu_utils.
DelayedPretty
(message)[source]¶ Bases:
object
Wraps a message and delays prettifying it until requested.
TODO(harlowja): remove this when https://github.com/celery/kombu/pull/454/ is merged and a release is made that contains it (since that pull request is equivalent and/or better than this).
Miscellaneous¶
Mixins¶
-
class
taskflow.utils.mixins.
StrMixin
[source]¶ Bases:
object
Mixin that helps deal with the PY2 and PY3 method differences.
http://lucumr.pocoo.org/2011/1/22/forwards-compatible-python/ explains why this is quite useful...