-
Notifications
You must be signed in to change notification settings - Fork 299
Faster message serialization #1064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…l.parser.isoparse
…ialize_objects for datetime validation
The failing tests on Windows appear to be unrelated to this PR: I've run both the main branch and this PR on Windows locally and observe similar errors related to "unclosed sockets". If the test is run individually it passes but when running in groups the error can move around, though generally the reported error is the same. c:\code\jupyter_client\tests\test_multikernelmanager.py::TestKernelManager::test_start_parallel_thread_kernels failed: cls = <class '_pytest.runner.CallInfo'>
func = <function call_and_report.<locals>.<lambda> at 0x0000013B0182FB00>
when = 'call'
reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)
@classmethod
def from_call(
cls,
func: Callable[[], TResult],
when: Literal["collect", "setup", "call", "teardown"],
reraise: Optional[
Union[Type[BaseException], Tuple[Type[BaseException], ...]]
] = None,
) -> "CallInfo[TResult]":
"""Call func, wrapping the result in a CallInfo.
:param func:
The function to call. Called without arguments.
:param when:
The phase in which the function is called.
:param reraise:
Exception or exceptions that shall propagate if raised by the
function, instead of being wrapped in the CallInfo.
"""
excinfo = None
start = timing.time()
precise_start = timing.perf_counter()
try:
> result: Optional[TResult] = func()
cls = <class '_pytest.runner.CallInfo'>
duration = 0.7103413999939221
excinfo = <ExceptionInfo PytestUnraisableExceptionWarning('Exception ignored in: <socket.socket fd=-1, family=2, type=1, proto=0...et.socket fd=2124, family=2, type=1, proto=0, laddr=(\'127.0.0.1\', 59458), raddr=(\'127.0.0.1\', 59459)>\n') tblen=11>
func = <function call_and_report.<locals>.<lambda> at 0x0000013B0182FB00>
precise_start = 60518.1109472
precise_stop = 60518.8212886
reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)
result = None
start = 1749603690.353999
stop = 1749603691.0643415
when = 'call'
c:\code\jupyter_client\.venv\Lib\site-packages\_pytest\runner.py:340:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\code\jupyter_client\.venv\Lib\site-packages\_pytest\runner.py:240: in <lambda>
lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise
item = <TestCaseFunction test_start_parallel_thread_kernels>
kwds = {}
runtest_hook = <HookCaller 'pytest_runtest_call'>
c:\code\jupyter_client\.venv\Lib\site-packages\pluggy\_hooks.py:512: in __call__
return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
firstresult = False
kwargs = {'item': <TestCaseFunction test_start_parallel_thread_kernels>}
self = <HookCaller 'pytest_runtest_call'>
c:\code\jupyter_client\.venv\Lib\site-packages\pluggy\_manager.py:120: in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
firstresult = False
hook_name = 'pytest_runtest_call'
kwargs = {'item': <TestCaseFunction test_start_parallel_thread_kernels>}
methods = [<HookImpl plugin_name='runner', plugin=<module '_pytest.runner' from 'c:\\code\\jupyter_client\\.venv\\Lib\\site-pack...nraisableexception' from 'c:\\code\\jupyter_client\\.venv\\Lib\\site-packages\\_pytest\\unraisableexception.py'>>, ...]
self = <_pytest.config.PytestPluginManager object at 0x0000013B7AD034D0>
c:\code\jupyter_client\.venv\Lib\site-packages\_pytest\threadexception.py:87: in pytest_runtest_call
yield from thread_exception_runtest_hook()
c:\code\jupyter_client\.venv\Lib\site-packages\_pytest\threadexception.py:63: in thread_exception_runtest_hook
yield
cm = <_pytest.threadexception.catch_threading_exception object at 0x0000013B018048F0>
c:\code\jupyter_client\.venv\Lib\site-packages\_pytest\unraisableexception.py:90: in pytest_runtest_call
yield from unraisable_exception_runtest_hook()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def unraisable_exception_runtest_hook() -> Generator[None, None, None]:
with catch_unraisable_exception() as cm:
try:
yield
finally:
if cm.unraisable:
if cm.unraisable.err_msg is not None:
err_msg = cm.unraisable.err_msg
else:
err_msg = "Exception ignored in"
msg = f"{err_msg}: {cm.unraisable.object!r}\n\n"
msg += "".join(
traceback.format_exception(
cm.unraisable.exc_type,
cm.unraisable.exc_value,
cm.unraisable.exc_traceback,
)
)
> warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=2, type=1, proto=0>
E
E Traceback (most recent call last):
E File "c:\code\jupyter_client\.venv\Lib\site-packages\traitlets\traitlets.py", line 632, in get
E value = obj._trait_values[self.name]
E ~~~~~~~~~~~~~~~~~^^^^^^^^^^^
E KeyError: 'kernel_spec_manager'
E
E During handling of the above exception, another exception occurred:
E
E Traceback (most recent call last):
E File "c:\code\jupyter_client\.venv\Lib\site-packages\traitlets\config\configurable.py", line 179, in _load_config
E with self.hold_trait_notifications():
E ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
E ResourceWarning: unclosed <socket.socket fd=2124, family=2, type=1, proto=0, laddr=('127.0.0.1', 59458), raddr=('127.0.0.1', 59459)>
cm = <_pytest.unraisableexception.catch_unraisable_exception object at 0x0000013B018055B0>
err_msg = 'Exception ignored in'
msg = 'Exception ignored in: <socket.socket fd=-1, family=2, type=1, proto=0>\n\nTraceback (most recent call last):\n File ...losed <socket.socket fd=2124, family=2, type=1, proto=0, laddr=(\'127.0.0.1\', 59458), raddr=(\'127.0.0.1\', 59459)>\n'
c:\code\jupyter_client\.venv\Lib\site-packages\_pytest\unraisableexception.py:80: PytestUnraisableExceptionWarning |
I've almost got the CI back into a healthy state in #1076 then I'll come back here. I think this looks great! |
Co-authored-by: M Bussonnier <[email protected]>
This PR provides faster pack and unpack defaults by utilizing
orjson
a "fast, correct JSON library".Support is also added for msgpack.
New functions
orjson_packer
orjson_unpacker
msgpack_packer
msgpack_unpacker
Performance comparison
Code