Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge commit '231252516' into dinsic
Browse files Browse the repository at this point in the history
* commit '231252516':
  Fix "argument of type 'ObservableDeferred' is not iterable" error (#7708)
  • Loading branch information
anoadragon453 committed Aug 3, 2020
2 parents 3017e1d + 2312525 commit 5c4e0e6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog.d/7708.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixs a long standing bug which resulted in an exception: "TypeError: argument of type 'ObservableDeferred' is not iterable".
9 changes: 5 additions & 4 deletions synapse/storage/data_stores/main/receipts.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from synapse.storage._base import SQLBaseStore, make_in_list_sql_clause
from synapse.storage.database import Database
from synapse.storage.util.id_generators import StreamIdGenerator
from synapse.util.async_helpers import ObservableDeferred
from synapse.util.caches.descriptors import cached, cachedInlineCallbacks, cachedList
from synapse.util.caches.stream_change_cache import StreamChangeCache

Expand Down Expand Up @@ -300,10 +301,10 @@ def _invalidate_get_users_with_receipts_in_room(
room_id, None, update_metrics=False
)

# first handle the Deferred case
if isinstance(res, defer.Deferred):
if res.called:
res = res.result
# first handle the ObservableDeferred case
if isinstance(res, ObservableDeferred):
if res.has_called():
res = res.get_result()
else:
res = None

Expand Down
2 changes: 1 addition & 1 deletion synapse/util/async_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def observe(self) -> defer.Deferred:
This returns a brand new deferred that is resolved when the underlying
deferred is resolved. Interacting with the returned deferred does not
effect the underdlying deferred.
effect the underlying deferred.
"""
if not self._result:
d = defer.Deferred()
Expand Down

0 comments on commit 5c4e0e6

Please sign in to comment.