summaryrefslogtreecommitdiffstats
path: root/deluge/log.py
diff options
context:
space:
mode:
authorChase Sterling <chase.sterling@gmail.com>2022-02-01 21:51:08 -0500
committerCalum Lind <calumlind+deluge@gmail.com>2022-02-06 16:42:13 +0000
commitb76f2c0f207ae271fb1533b6f2ec91d2c9d5b92a (patch)
tree885a0e0839bf8114848fbad6cd4ea35c4feca4f4 /deluge/log.py
parentbd88f78af638ec9fafd38cd7787f2d93777428df (diff)
downloaddeluge-b76f2c0f207ae271fb1533b6f2ec91d2c9d5b92a.tar.gz
deluge-b76f2c0f207ae271fb1533b6f2ec91d2c9d5b92a.tar.bz2
deluge-b76f2c0f207ae271fb1533b6f2ec91d2c9d5b92a.zip
[Decorators] Add maybe_coroutine decorator
- Clean up callback hell by making more code inline - Use async/await syntax as it has more modern niceties than inlineCallbacks - Also gets us closer if we want to transition to asyncio in the future - `await` is usable in places that `yield` is not. e.g. `return await thething` `func(await thething, 'otherparam')` - IDEs know async semantics of async/await syntax to help more than with `inlineCallbacks` - `maybe_coroutine` decorator has nice property (over `ensureDeferred`) that when used in a chain of other coroutines, they won't be wrapped in deferreds on each level, and so traceback will show each `await` call leading to the error. - All async functions wrapped in `maybe_coroutine` are 100% backwards compatible with a regular Deferred returning function. Whether called from a coroutine or not. - Use Deferred type hints as strings since older versions of twisted (<21.7) don't support generic Deferred type hinting.
Diffstat (limited to 'deluge/log.py')
0 files changed, 0 insertions, 0 deletions