-
-
Notifications
You must be signed in to change notification settings - Fork 373
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
Kernel subshells (JEP91) implementation #1249
Merged
Merged
Changes from 28 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
4ea2d04
Separate thread to handle incoming shell channel messages
ianthomas23 b801b79
Add supported_features entry to kernel_info_reply
ianthomas23 0ddc1b7
Dummy subshell control message implementations
ianthomas23 17bd0f6
SubshellCache
ianthomas23 62e5d21
Subshell threads with correct lifetime but don't yet execute code
ianthomas23 2f8273b
Extract subshell_id, and handle message in correct subshell
ianthomas23 1cc8892
Add subshell test_execution_count
ianthomas23 f5b664d
Use dataclass for Subshell, clean up correctly
ianthomas23 c3fd89e
Test can create subshell whilst main subshell is executing
ianthomas23 7fc1d6e
Add %subshell magic
ianthomas23 b8b7af5
Temporary mutex for execute_reply from subshells
ianthomas23 7dd3407
Process subshell control messages in SubshellCache
ianthomas23 27ead02
Send shell reply messages via shell channel thread
ianthomas23 1e79f4c
Poll subshell inproc pair sockets in SubshellManager
ianthomas23 365d231
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 90c3a20
Better error checking
ianthomas23 2fa7365
Pin anyio <= 4.3.0
ianthomas23 ad32ea7
Remove anyio pin following fix in PR 1253
ianthomas23 f498045
Fix type annotations on old python
ianthomas23 48f7630
Make tests more robust
ianthomas23 c79ba79
Isolate each subshell test
ianthomas23 97e3e91
Avoid high CPU load when waiting for subshell reply messages
ianthomas23 e19273c
Replace use of zmq Poller with better anyio task handling
ianthomas23 a050784
Wrap sending via shell_socket with a lock
ianthomas23 9669fcd
More type annotations
ianthomas23 b72d1da
Ensure abort reply messages are sent via the subshell manager
ianthomas23 e4fa75d
Add modules to docs API
ianthomas23 a708e0e
Increase timings of test_subshells::test_execution_counts
ianthomas23 2a91bcd
Use _tasks_and_args in BaseThread
ianthomas23 4bcd59e
Use super when calling base class constructors
ianthomas23 b644f9e
Improve thread classes
ianthomas23 924015a
Always return supported_features in kernel_info
ianthomas23 a1fb1de
Make _supports_kernel_subshells a property
ianthomas23 be5c83a
Clarify socket=None in process_shell_message
ianthomas23 9109cc8
Improved use of thread names
ianthomas23 d17c77f
Small changes
ianthomas23 5715dd0
More type annotations
ianthomas23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,18 @@ | ||
"""A thread for a control channel.""" | ||
from threading import Event, Thread | ||
|
||
from anyio import create_task_group, run, to_thread | ||
from .thread import BaseThread | ||
|
||
CONTROL_THREAD_NAME = "Control" | ||
|
||
|
||
class ControlThread(Thread): | ||
class ControlThread(BaseThread): | ||
"""A thread for a control channel.""" | ||
|
||
def __init__(self, **kwargs): | ||
"""Initialize the thread.""" | ||
Thread.__init__(self, name=CONTROL_THREAD_NAME, **kwargs) | ||
self.pydev_do_not_trace = True | ||
self.is_pydev_daemon_thread = True | ||
self.__stop = Event() | ||
self._task = None | ||
|
||
def set_task(self, task): | ||
self._task = task | ||
super().__init__(name=CONTROL_THREAD_NAME, **kwargs) | ||
|
||
def run(self): | ||
"""Run the thread.""" | ||
self.name = CONTROL_THREAD_NAME | ||
run(self._main) | ||
|
||
async def _main(self): | ||
async with create_task_group() as tg: | ||
if self._task is not None: | ||
tg.start_soon(self._task) | ||
await to_thread.run_sync(self.__stop.wait) | ||
tg.cancel_scope.cancel() | ||
|
||
def stop(self): | ||
"""Stop the thread. | ||
|
||
This method is threadsafe. | ||
""" | ||
self.__stop.set() | ||
super().run() |
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is unnecessary now Thread have setter/getter and
super().__init__
should set the private name directly.Maybe try to put an assert ==, and if test are passing, just remove the override of the run method ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the name duplication in
b644f9e7
and9109cc8
without causing any problems.