Skip to content

Commit

Permalink
[MAINT] Workaround aiohttp issue
Browse files Browse the repository at this point in the history
- Prevent us from storing errorneous status code in response code stats

References: aio-libs/aiohttp#3641
  • Loading branch information
Daniel Armbruster committed May 7, 2021
1 parent 4e75e10 commit 1243bfb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ async def run(self, route, req_method="GET", context=None, **req_kwargs):
await self.handle_413()
elif resp_status in FDSNWS_NO_CONTENT_CODES:
logger.info(msg)
# https://github.com/aio-libs/aiohttp/issues/3641
elif (
resp_status == 400 and "invalid constant string" == err.message
):
resp_status = 204
logger.info(
"Excess found in read (reset status code to "
f"{resp_status}). Original aiohttp error: {msg}"
)
else:
await self.handle_error(msg=msg, context=context)

Expand Down
19 changes: 19 additions & 0 deletions eidaws.federator/eidaws/federator/utils/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,16 @@ async def _run(
)
elif resp_status in FDSNWS_NO_CONTENT_CODES:
logger.info(msg)
# https://github.com/aio-libs/aiohttp/issues/3641
elif (
resp_status == 400
and "invalid constant string" == err.message
):
resp_status = 204
logger.info(
"Excess found in read (reset status code to "
f"{resp_status}). Original aiohttp error: {msg}"
)
else:
await self.handle_error(msg=msg, context=context)
break
Expand Down Expand Up @@ -508,6 +518,15 @@ async def _fetch(
await self.handle_413(context=context)
elif resp_status in FDSNWS_NO_CONTENT_CODES:
logger.info(msg)
# https://github.com/aio-libs/aiohttp/issues/3641
elif (
resp_status == 400 and "invalid constant string" == err.message
):
resp_status = 204
logger.info(
"Excess found in read (reset status code to "
f"{resp_status}). Original aiohttp error: {msg}"
)
else:
await self.handle_error(msg=msg, context=context)

Expand Down

0 comments on commit 1243bfb

Please sign in to comment.