mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Use observable deferreds because they are sane
This commit is contained in:
parent
8a8ad46f48
commit
c7daf3136c
@ -20,6 +20,7 @@ from twisted.internet import defer
|
|||||||
from synapse.http import servlet
|
from synapse.http import servlet
|
||||||
from synapse.http.servlet import parse_json_object_from_request
|
from synapse.http.servlet import parse_json_object_from_request
|
||||||
from synapse.rest.client.v1.transactions import HttpTransactionCache
|
from synapse.rest.client.v1.transactions import HttpTransactionCache
|
||||||
|
from synapse.util.async import ObservableDeferred
|
||||||
|
|
||||||
from ._base import client_v2_patterns
|
from ._base import client_v2_patterns
|
||||||
|
|
||||||
@ -47,14 +48,14 @@ class SendToDeviceRestServlet(servlet.RestServlet):
|
|||||||
def on_PUT(self, request, message_type, txn_id):
|
def on_PUT(self, request, message_type, txn_id):
|
||||||
try:
|
try:
|
||||||
res_deferred = self.txns.get_client_transaction(request, txn_id)
|
res_deferred = self.txns.get_client_transaction(request, txn_id)
|
||||||
res = yield res_deferred
|
res = yield res_deferred.observe()
|
||||||
defer.returnValue(res)
|
defer.returnValue(res)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
res_deferred = self._put(request, message_type, txn_id)
|
res_deferred = ObservableDeferred(self._put(request, message_type, txn_id))
|
||||||
self.txns.store_client_transaction(request, txn_id, res_deferred)
|
self.txns.store_client_transaction(request, txn_id, res_deferred)
|
||||||
res = yield res_deferred
|
res = yield res_deferred.observe()
|
||||||
defer.returnValue(res)
|
defer.returnValue(res)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
Loading…
Reference in New Issue
Block a user