This is just for convenience and to write less code since we are using
this pattern a lot.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
#!/usr/bin/python
+import asyncio
+import functools
+
+def run_in_thread(func):
+ """
+ Decorator to run a synchronous function in a separate thread.
+ """
+ @functools.wraps(func)
+ async def wrapper(*args, **kwargs):
+ return await asyncio.to_thread(func, *args, **kwargs)
+
+ return wrapper
+
class lazy_property(property):
"""
The property is only computed once and then being