Remote exception names are cut to 128 identifier characters before a class is built for them
This commit is contained in:
@@ -17,6 +17,7 @@ import itertools
|
||||
import logging
|
||||
import os
|
||||
import queue
|
||||
import re
|
||||
import select
|
||||
import signal
|
||||
import subprocess
|
||||
@@ -102,6 +103,8 @@ class NodeCancelled(RemoteError):
|
||||
#: node code chose, so an unbounded cache is a node raising a class named after
|
||||
#: its loop counter.
|
||||
MAX_REMOTE_TYPES = 256
|
||||
#: How long one of those names may be. A remote worker's comes off the wire.
|
||||
MAX_REMOTE_NAME = 128
|
||||
|
||||
_remote_types: dict[str, type[RemoteError]] = {}
|
||||
|
||||
@@ -113,6 +116,7 @@ def _remote_class(name: str) -> type[RemoteError]:
|
||||
the author still reads ``ValueError: bad input`` rather than the name of
|
||||
the transport that carried it.
|
||||
"""
|
||||
name = re.sub(r"\W", "_", name[:MAX_REMOTE_NAME]) or "RemoteError"
|
||||
cls = _remote_types.get(name)
|
||||
if cls is not None:
|
||||
return cls
|
||||
|
||||
Reference in New Issue
Block a user