libb.threaded

threaded(fn)[source]

Decorator to run function in a separate thread.

Returns a Future that can be used to get the result.

Example:

>>> class MyClass:
...     @threaded
...     def get_my_value(self):
...         return 1
>>> my_obj = MyClass()
>>> fut = my_obj.get_my_value()  # this will run in a separate thread
>>> fut.result()  # will block until result is computed
1