-
Notifications
You must be signed in to change notification settings - Fork 744
[XPU] fix zmq err catch #7844
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
+19
−3
Merged
[XPU] fix zmq err catch #7844
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| """ | ||
|
|
||
| import os | ||
| import pickle | ||
| import threading | ||
| import time | ||
| import traceback | ||
|
|
@@ -110,7 +111,11 @@ def recv_json(self, flags: int = 0): | |
| try: | ||
| # receive from socket | ||
| msg = self.socket.recv(flags=flags) | ||
| data_dict = self.socket._deserialize(msg, lambda buf: jsonapi.loads(buf)) | ||
| try: | ||
| data_dict = self.socket._deserialize(msg, lambda buf: jsonapi.loads(buf)) | ||
| except (UnicodeDecodeError, ValueError) as e: | ||
| llm_logger.warning(f"recv_json decode failed, msg={msg}, err={e}") | ||
| raise | ||
|
|
||
| # collect zmq recv metrics | ||
| _zmq_metrics_stats.msg_bytes_recv_total += len(msg) | ||
|
|
@@ -152,7 +157,11 @@ def recv_pyobj(self, flags: int = 0): | |
| _zmq_metrics_stats = ZMQMetricsStats() | ||
| self._ensure_socket() | ||
| data_bytes = self.socket.recv(flags=flags) | ||
| envelope = ForkingPickler.loads(data_bytes) | ||
| try: | ||
| envelope = ForkingPickler.loads(data_bytes) | ||
| except (UnicodeDecodeError, ValueError, pickle.UnpicklingError) as e: | ||
| llm_logger.warning(f"recv_pyobj decode failed, msg={data_bytes}, err={e}") | ||
|
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. 🟡 建议 将原始消息字节 建议只打印字节长度: llm_logger.warning(f"recv_pyobj decode failed, msg_len={len(data_bytes)}, err={e}") |
||
| raise | ||
| if isinstance(envelope, dict): | ||
| if "__meta" in envelope and "send_ts" in envelope["__meta"]: | ||
| _zmq_metrics_stats.msg_recv_total += 1 | ||
|
|
@@ -539,7 +548,12 @@ def recv_control_cmd(self): | |
| """ | ||
| self._ensure_socket() | ||
| try: | ||
| client, _, task_data = self.socket.recv_multipart(flags=zmq.NOBLOCK) | ||
| frames = self.socket.recv_multipart(flags=zmq.NOBLOCK) | ||
| if len(frames) < 2: | ||
| llm_logger.warning(f"recv_control_cmd: unexpected frame count {len(frames)}, dropping message") | ||
| return None | ||
| client = frames[0] | ||
| task_data = frames[-1] | ||
| task = msgpack.unpackb(task_data) | ||
| task_id_str = task["task_id"] | ||
| except zmq.Again: | ||
|
|
@@ -577,6 +591,8 @@ def close(self): | |
| llm_logger.info("ZMQ server is closing connection...") | ||
| try: | ||
| if self.socket is not None and not self.socket.closed: | ||
| if self.address: | ||
| self.socket.unbind(self.address) | ||
|
cmcamdy marked this conversation as resolved.
cmcamdy marked this conversation as resolved.
|
||
| self.socket.close() | ||
| if not self.context.closed: | ||
| self.context.term() | ||
|
|
||
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.
🟡 建议 将原始消息字节
msg直接打印到 warning 日志,若消息包含 prompt 等敏感内容,可能造成信息泄漏,且大消息体会产生大量日志。建议只打印字节长度: