mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-03 19:07:47 +03:00
[Common] Fix Twisted 24.x no longer calling addCallbacks in Deferred subclass
A change to Deferred logic in 24.10 means that `addCallbacks` is no
longer being called in Deferred methods. This is a problem since our
subclass of Deferred for coroutines was using that mechanism to check
awaited status.
Fixed by extending each method that requires awaited status check.
Reference: https://github.com/twisted/twisted/pull/12283
Reference: 4d04b64b77
This commit is contained in:
parent
8df36c454b
commit
cb182daaaf
1 changed files with 17 additions and 1 deletions
|
@ -196,11 +196,27 @@ class CoroutineDeferred(defer.Deferred):
|
|||
d = defer.ensureDeferred(self.coro)
|
||||
d.chainDeferred(self)
|
||||
|
||||
def addCallbacks(self, *args, **kwargs): # noqa: N802
|
||||
def _callback_activate(self):
|
||||
"""Verify awaited status before calling activate."""
|
||||
assert not self.awaited, 'Cannot add callbacks to an already awaited coroutine.'
|
||||
self.activate()
|
||||
|
||||
def addCallback(self, *args, **kwargs): # noqa: N802
|
||||
self._callback_activate()
|
||||
return super().addCallback(*args, **kwargs)
|
||||
|
||||
def addCallbacks(self, *args, **kwargs): # noqa: N802
|
||||
self._callback_activate()
|
||||
return super().addCallbacks(*args, **kwargs)
|
||||
|
||||
def addErrback(self, *args, **kwargs): # noqa: N802
|
||||
self._callback_activate()
|
||||
return super().addErrback(*args, **kwargs)
|
||||
|
||||
def addBoth(self, *args, **kwargs): # noqa: N802
|
||||
self._callback_activate()
|
||||
return super().addBoth(*args, **kwargs)
|
||||
|
||||
|
||||
_RetT = TypeVar('_RetT')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue