Commit 171c2a60 authored by Kirill Smelkov's avatar Kirill Smelkov

client: verify: Move lastTransaction call into main try/except that covers whole operation

From https://github.com/zopefoundation/ZEO/pull/182#issuecomment-826630195 :

For `protocol.fut('lastTransaction')` vs `ClientDisconnected` in verify - I
would suggest to do the following instead: just move up the try/except that is
_already_ covering the code in verify a bit up - to also cover that
lastTransaction call. This try / except already catches `except Exception` and
does `self.register_failed(protocol, exc)` on a failure:

https://github.com/zopefoundation/ZEO/blob/1070adcbd17b83b9515c43b48ca38687783793e4/src/ZEO/asyncio/client.py#L488-L535

So if we just move its beginning `try` a bit up in here to also cover
`lastTransaction` call here:

https://github.com/zopefoundation/ZEO/blob/1070adcbd17b83b9515c43b48ca38687783793e4/src/ZEO/asyncio/client.py#L485-L488

it will work out automatically. It will work correctly because
`ClientDisconnected` is inheriting as

    ClientDisconnected -> ClientStorageError -> StorageError -> POSError -> Exception

It is also more logical to wrap the whole operation in verify in such a
try/except block, so that if _anything_ at _any_ point fails, we mark the whole
operation as failed.
parent 243909ce
......@@ -485,17 +485,10 @@ class Client(object):
self.verify_invalidation_queue = [] # See comment in init :(
protocol = self.protocol
if server_tid is None:
try:
try:
if server_tid is None:
server_tid = yield protocol.fut('lastTransaction')
except ClientDisconnected as exc:
# If needed, after consideration more exceptions can be
# caught here. Possibly you want to include this into the
# following try clause.
del self.protocol
self.register_failed(protocol, exc)
try:
cache = self.cache
if cache:
cache_tid = cache.getLastTid()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment