-
Notifications
You must be signed in to change notification settings - Fork 298
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
Open
fleming79
wants to merge
9
commits into
jupyter:main
Choose a base branch
from
fleming79:orjson
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
krassowski
reviewed
Jun 9, 2025
…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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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