Catch `KeyError` within Threadless executors (#1396)

This commit is contained in:
Abhinav Singh 2024-04-23 18:51:53 +05:30 committed by GitHub
parent 78248474bc
commit 380e0cc3ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 37 additions and 9 deletions

1
.gitignore vendored
View File

@ -36,6 +36,5 @@ build
pyreverse.png
profile.svg
*-pre-push
jaxl-api-credentials*.json

16
.vscode/settings.json vendored
View File

@ -41,5 +41,19 @@
"python.linting.flake8Args": ["--config", ".flake8"],
"python.linting.mypyEnabled": true,
"python.formatting.provider": "autopep8",
"autoDocstring.docstringFormat": "sphinx"
"autoDocstring.docstringFormat": "sphinx",
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.py$",
"isAsync": false,
"cmd": "./.venv/bin/autoflake --in-place --remove-all-unused-imports \"${file}\""
},
{
"match": "\\.py$",
"isAsync": false,
"cmd": "./.venv/bin/isort \"${file}\""
}
]
}
}

View File

@ -191,13 +191,21 @@ class Threadless(ABC, Generic[T]):
#
# TODO: Also remove offending work from pool to avoid spin loop.
elif fileno != -1:
try:
self.selector.register(fileno, events=mask, data=work_id)
self.registered_events_by_work_ids[work_id][fileno] = mask
logger.debug(
'fd#{0} registered for mask#{1} by work#{2}'.format(
fileno, mask, work_id,
fileno,
mask,
work_id,
),
)
except KeyError as exc:
logger.warning(
'KeyError when trying to register fd#{0}'.format(fileno),
exc_info=exc,
)
async def _update_conn_pool_events(self) -> None:
if not self._upstream_conn_pool:

View File

@ -216,6 +216,13 @@ class HttpParser:
self.has_header(b'Connection') and \
self.has_header(b'Upgrade')
@property
def is_websocket_upgrade(self) -> bool:
return (
self.is_connection_upgrade
and self.header(b'upgrade').lower() == b'websocket'
)
@property
def is_https_tunnel(self) -> bool:
"""Returns true for HTTPS CONNECT tunnel request."""