Threadful
Python Threads - from Dreadful to Threadful
Installation
pip install threadful
Usage
from threadful import thread
@thread
def some_function():
time.sleep(10)
return " done "
some_function().then(lambda result: result.strip().then(lambda result: print(result))
promise = some_function()
promise.result()
time.sleep(15)
promise.result()
result = promise.join()
@thread()
def raises() -> str:
raises ValueError()
promise = raises().catch(lambda err: TypeError())
promise.join()
promise.result()
promise = raises().catch(lambda err: "Something went wrong")
promise.join()
License
threadful
is distributed under the terms of the MIT license.
Changelog
See CHANGELOG.md