-
-
Notifications
You must be signed in to change notification settings - Fork 761
Remove the requirements to add comm to every handler #5820
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0416d33
Remove the requirements to add comm to every handler
fjetter 44077d3
review comments
fjetter a16c7e7
Remove remove_worker type annotations due to cythonization error
fjetter fc864d8
Include deprecation cycle and allow usage beyond first position
fjetter 5030cd7
add partialmethod
fjetter 4205e15
use getitem instead of get
fjetter e3b1f0c
simplify
fjetter 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 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
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||
| import threading | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import traceback | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import uuid | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import warnings | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import weakref | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from collections import defaultdict | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from collections.abc import Container | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -98,6 +99,26 @@ def _raise(*args, **kwargs): | |||||||||||||||||||||||||||||||||||||||||||||||||||
| LOG_PDB = dask.config.get("distributed.admin.pdb-on-err") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _expects_comm(func): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| sig = inspect.signature(func) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if "comm" in sig.parameters or "stream" in sig.parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| params = list(sig.parameters) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if len(params) > 1 and params[1] in ["comm", "stream"]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if "stream" in sig.parameters: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fname = func.__name__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| except AttributeError: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # e.g. partials don't have __name__ We don't want to crash | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| # just because we're trying to raise a warning | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fname = "unknown" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| warnings.warn( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| f"Calling the first arugment of a RPC handler `stream` is deprecated. Defining this argument is optional. Either remove the arugment or rename it to `comm`. Instead got {fname}{sig}", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| FutureWarning, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return True | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| return False | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| class Server: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| """Dask Distributed Server | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -379,7 +400,7 @@ def port(self): | |||||||||||||||||||||||||||||||||||||||||||||||||||
| _, self._port = get_address_host_port(self.address) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return self._port | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| def identity(self, comm=None) -> dict[str, str]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| def identity(self) -> dict[str, str]: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return {"type": type(self).__name__, "id": self.id} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _to_dict( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -404,7 +425,7 @@ def _to_dict( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| info = {k: v for k, v in info.items() if k not in exclude} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return recursive_to_dict(info, exclude=exclude) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| def echo(self, comm=None, data=None): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| def echo(self, data=None): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return data | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| async def listen(self, port_or_addr=None, allow_offload=True, **kwargs): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -514,7 +535,10 @@ async def handle_comm(self, comm): | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| logger.debug("Calling into handler %s", handler.__name__) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| result = handler(comm, **msg) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if _expects_comm(handler): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| result = handler(comm, **msg) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| result = handler(**msg) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if inspect.isawaitable(result): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| result = asyncio.ensure_future(result) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| self._ongoing_coroutines.add(result) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
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
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
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
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
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
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
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
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
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.