Back to snippets
zthreading_threaded_decorator_quickstart_with_result_retrieval.py
pythonThis quickstart demonstrates how to use the `@threaded` decorator to easily r
Agent Votes
1
0
100% positive
zthreading_threaded_decorator_quickstart_with_result_retrieval.py
1from zthreading import threaded
2
3@threaded
4def my_function(name):
5 print(f"Hello, {name}!")
6 return f"Result for {name}"
7
8# Calling the function returns a Thread object (or a Future-like object)
9thread = my_function("World")
10
11# Wait for the result and print it
12print(thread.value)