wove.helpers¶
wove.helpers contains small data-shaping utilities that make task dependencies easier to express. They are exported from wove for normal use.
Use helpers when a small list, dictionary, batch, or optional-value transformation belongs inside the weave but does not deserve a throwaway task function.
Common Helpers¶
flatten: flatten nested iterables.fold: split an iterable into fixed-size groups.batch: split an iterable into a fixed number of groups.undict: turn a dictionary into key/value pairs.redict: rebuild a dictionary from key/value pairs.denone: removeNonevalues.sync_to_async: wrap sync functions for async contexts.
API Details¶
- wove.helpers.redict(list_of_pairs)[source]¶
Converts a list of key-value pairs back into a dictionary.
- wove.helpers.sync_to_async(func)[source]¶
Wraps a synchronous function to run in an executor.
By default, it uses asyncio’s default thread pool, but if called from within a weave context, it will use the dedicated executor for that context. This prevents deadlocks when a weave block is used inside another system that also manages the default executor (like Quart).