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

Commit

Permalink
Merge pull request #3142 from matrix-org/rav/reraise
Browse files Browse the repository at this point in the history
reraise exceptions more carefully
  • Loading branch information
richvdh authored Apr 27, 2018
2 parents 05ba7e3 + 6493b22 commit 41d4b07
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
16 changes: 10 additions & 6 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
import httplib
import itertools
import logging
import sys

from signedjson.key import decode_verify_key_bytes
from signedjson.sign import verify_signed_json
import six
from twisted.internet import defer
from unpaddedbase64 import decode_base64

Expand Down Expand Up @@ -1513,12 +1515,14 @@ def _handle_new_event(self, origin, event, state=None, auth_events=None,
backfilled=backfilled,
)
except: # noqa: E722, as we reraise the exception this is fine.
# Ensure that we actually remove the entries in the push actions
# staging area
logcontext.preserve_fn(
self.store.remove_push_actions_from_staging
)(event.event_id)
raise
tp, value, tb = sys.exc_info()

logcontext.run_in_background(
self.store.remove_push_actions_from_staging,
event.event_id,
)

six.reraise(tp, value, tb)

if not backfilled:
# this intentionally does not yield: we don't care about the result
Expand Down
21 changes: 14 additions & 7 deletions synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
import simplejson
import sys

from canonicaljson import encode_canonical_json
import six
from twisted.internet import defer, reactor
from twisted.python.failure import Failure

Expand All @@ -34,11 +40,6 @@

from ._base import BaseHandler

from canonicaljson import encode_canonical_json

import logging
import simplejson

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -729,8 +730,14 @@ def handle_new_client_event(
except: # noqa: E722, as we reraise the exception this is fine.
# Ensure that we actually remove the entries in the push actions
# staging area, if we calculated them.
preserve_fn(self.store.remove_push_actions_from_staging)(event.event_id)
raise
tp, value, tb = sys.exc_info()

run_in_background(
self.store.remove_push_actions_from_staging,
event.event_id,
)

six.reraise(tp, value, tb)

@defer.inlineCallbacks
def persist_and_notify_client_event(
Expand Down

0 comments on commit 41d4b07

Please sign in to comment.