{"id":44313,"date":"2025-06-18T09:34:28","date_gmt":"2025-06-18T01:34:28","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/44313.html"},"modified":"2025-06-18T09:34:28","modified_gmt":"2025-06-18T01:34:28","slug":"python%e5%ae%9e%e4%be%8b%e9%a2%98%ef%bc%9a%e5%88%86%e5%b8%83%e5%bc%8f%e4%bb%bb%e5%8a%a1%e8%b0%83%e5%ba%a6%e7%b3%bb%e7%bb%9f","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/44313.html","title":{"rendered":"Python\u5b9e\u4f8b\u9898\uff1a\u5206\u5e03\u5f0f\u4efb\u52a1\u8c03\u5ea6\u7cfb\u7edf"},"content":{"rendered":"<h3 id=\"main-toc\">\u76ee\u5f55<\/h3>\n<p id=\"Python%E5%AE%9E%E4%BE%8B%E9%A2%98-toc\" style=\"margin-left:0px\">Python\u5b9e\u4f8b\u9898<\/p>\n<p id=\"%E9%A2%98%E7%9B%AE-toc\" style=\"margin-left:40px\">\u9898\u76ee<\/p>\n<p id=\"%E9%97%AE%E9%A2%98%E6%8F%8F%E8%BF%B0-toc\" style=\"margin-left:40px\">\u95ee\u9898\u63cf\u8ff0<\/p>\n<p id=\"%E8%B0%83%E5%BA%A6%E4%B8%AD%E5%BF%83%EF%BC%88Server%EF%BC%89%EF%BC%9A-toc\" style=\"margin-left:80px\">\u8c03\u5ea6\u4e2d\u5fc3&#xff08;Server&#xff09;&#xff1a;<\/p>\n<p id=\"%E5%B7%A5%E4%BD%9C%E8%8A%82%E7%82%B9%EF%BC%88Worker%EF%BC%89%EF%BC%9A-toc\" style=\"margin-left:80px\">\u5de5\u4f5c\u8282\u70b9&#xff08;Worker&#xff09;&#xff1a;<\/p>\n<p id=\"%E5%AE%A2%E6%88%B7%E7%AB%AF%EF%BC%88Client%EF%BC%89%EF%BC%9A-toc\" style=\"margin-left:80px\">\u5ba2\u6237\u7aef&#xff08;Client&#xff09;&#xff1a;<\/p>\n<p id=\"%E7%B3%BB%E7%BB%9F%E6%9E%B6%E6%9E%84-toc\" style=\"margin-left:40px\">\u7cfb\u7edf\u67b6\u6784<\/p>\n<p id=\"%E5%85%B3%E9%94%AE%E5%AE%9E%E7%8E%B0%E6%80%9D%E8%B7%AF-toc\" style=\"margin-left:40px\">\u5173\u952e\u5b9e\u73b0\u601d\u8def<\/p>\n<p id=\"%E6%A0%B8%E5%BF%83%E4%BB%A3%E7%A0%81%E6%A1%86%E6%9E%B6%EF%BC%88%E8%B0%83%E5%BA%A6%E4%B8%AD%E5%BF%83%E9%83%A8%E5%88%86%EF%BC%89-toc\" style=\"margin-left:40px\">\u6838\u5fc3\u4ee3\u7801\u6846\u67b6&#xff08;\u8c03\u5ea6\u4e2d\u5fc3\u90e8\u5206&#xff09;<\/p>\n<p id=\"%E9%9A%BE%E7%82%B9%E5%88%86%E6%9E%90-toc\" style=\"margin-left:40px\">\u96be\u70b9\u5206\u6790<\/p>\n<p id=\"%E6%89%A9%E5%B1%95%E6%96%B9%E5%90%91-toc\" style=\"margin-left:40px\">\u6269\u5c55\u65b9\u5411<\/p>\n<\/p>\n<h2 id=\"Python%E5%AE%9E%E4%BE%8B%E9%A2%98\" style=\"background-color:transparent\">Python\u5b9e\u4f8b\u9898<\/h2>\n<h3 id=\"%E9%A2%98%E7%9B%AE\">\u9898\u76ee<\/h3>\n<p>\u5206\u5e03\u5f0f\u4efb\u52a1\u8c03\u5ea6\u7cfb\u7edf<\/p>\n<h3 id=\"%E9%97%AE%E9%A2%98%E6%8F%8F%E8%BF%B0\" style=\"background-color:transparent\">\u95ee\u9898\u63cf\u8ff0<\/h3>\n<p>\u8bbe\u8ba1\u4e00\u4e2a\u7b80\u5316\u7248\u5206\u5e03\u5f0f\u4efb\u52a1\u8c03\u5ea6\u7cfb\u7edf&#xff0c;\u5305\u542b\u4ee5\u4e0b\u7ec4\u4ef6&#xff1a;<\/p>\n<ul>\n<li>\n<h4 id=\"%E8%B0%83%E5%BA%A6%E4%B8%AD%E5%BF%83%EF%BC%88Server%EF%BC%89%EF%BC%9A\">\u8c03\u5ea6\u4e2d\u5fc3&#xff08;Server&#xff09;&#xff1a;<\/h4>\n<ul>\n<li>\u63a5\u6536\u5ba2\u6237\u7aef\u4efb\u52a1\u63d0\u4ea4<\/li>\n<li>\u7ef4\u62a4\u4efb\u52a1\u961f\u5217\u548c\u5de5\u4f5c\u8282\u70b9\u72b6\u6001<\/li>\n<li>\u5206\u914d\u4efb\u52a1\u5230\u7a7a\u95f2\u8282\u70b9<\/li>\n<li>\u5b58\u50a8\u4efb\u52a1\u6267\u884c\u7ed3\u679c\u548c\u65e5\u5fd7<\/li>\n<\/ul>\n<\/li>\n<li>\n<h4 id=\"%E5%B7%A5%E4%BD%9C%E8%8A%82%E7%82%B9%EF%BC%88Worker%EF%BC%89%EF%BC%9A\">\u5de5\u4f5c\u8282\u70b9&#xff08;Worker&#xff09;&#xff1a;<\/h4>\n<ul>\n<li>\u8fde\u63a5\u8c03\u5ea6\u4e2d\u5fc3\u83b7\u53d6\u4efb\u52a1<\/li>\n<li>\u6267\u884c\u8ba1\u7b97\u5bc6\u96c6\u578b\u4efb\u52a1&#xff08;\u5982\u6570\u5b66\u5efa\u6a21\u3001\u6570\u636e\u5904\u7406&#xff09;<\/li>\n<li>\u8fd4\u56de\u4efb\u52a1\u7ed3\u679c<\/li>\n<\/ul>\n<\/li>\n<li>\n<h4 id=\"%E5%AE%A2%E6%88%B7%E7%AB%AF%EF%BC%88Client%EF%BC%89%EF%BC%9A\">\u5ba2\u6237\u7aef&#xff08;Client&#xff09;&#xff1a;<\/h4>\n<ul>\n<li>\u63d0\u4ea4\u4efb\u52a1\u5230\u8c03\u5ea6\u4e2d\u5fc3<\/li>\n<li>\u67e5\u8be2\u4efb\u52a1\u72b6\u6001\u548c\u7ed3\u679c<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3 id=\"%E7%B3%BB%E7%BB%9F%E6%9E%B6%E6%9E%84\">\u7cfb\u7edf\u67b6\u6784<\/h3>\n<p>&#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;     &#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;     &#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;<br \/>\n|    \u5ba2\u6237\u7aef      |&lt;&#8212;&gt;|    \u8c03\u5ea6\u4e2d\u5fc3    |&lt;&#8212;&gt;|    \u5de5\u4f5c\u8282\u70b91    |<br \/>\n&#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;     &#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;     &#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;<br \/>\n                                        ^<br \/>\n                                        |<br \/>\n&#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;     &#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;     &#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;<br \/>\n|    \u5ba2\u6237\u7aef      |&lt;&#8212;&gt;|    \u8c03\u5ea6\u4e2d\u5fc3    |&lt;&#8212;&gt;|    \u5de5\u4f5c\u8282\u70b92    |<br \/>\n&#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;     &#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;     &#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;<\/p>\n<h3 id=\"%E5%85%B3%E9%94%AE%E5%AE%9E%E7%8E%B0%E6%80%9D%E8%B7%AF\">\u5173\u952e\u5b9e\u73b0\u601d\u8def<\/h3>\n<ul>\n<li>\u4f7f\u7528Socket\u5b9e\u73b0\u7f51\u7edc\u901a\u4fe1&#xff08;\u6216\u9009\u62e9ZeroMQ\u7b49\u66f4\u4e13\u4e1a\u7684\u6d88\u606f\u961f\u5217&#xff09;<\/li>\n<li>\u7528SQLite\/PostgreSQL\u5b58\u50a8\u4efb\u52a1\u4fe1\u606f\u548c\u7ed3\u679c<\/li>\n<li>\u91c7\u7528multiprocessing\u6216concurrent.futures\u5904\u7406\u5e76\u53d1\u4efb\u52a1<\/li>\n<li>\u8bbe\u8ba1\u81ea\u5b9a\u4e49\u901a\u4fe1\u534f\u8bae&#xff08;\u5982 JSON \u683c\u5f0f\u6d88\u606f&#xff09;<\/li>\n<li>\u5b9e\u73b0\u5fc3\u8df3\u673a\u5236\u68c0\u6d4b\u5de5\u4f5c\u8282\u70b9\u5b58\u6d3b\u72b6\u6001<\/li>\n<li>\u652f\u6301\u4efb\u52a1\u4f18\u5148\u7ea7\u548c\u8d85\u65f6\u5904\u7406<\/li>\n<\/ul>\n<h3 id=\"%E6%A0%B8%E5%BF%83%E4%BB%A3%E7%A0%81%E6%A1%86%E6%9E%B6%EF%BC%88%E8%B0%83%E5%BA%A6%E4%B8%AD%E5%BF%83%E9%83%A8%E5%88%86%EF%BC%89\">\u6838\u5fc3\u4ee3\u7801\u6846\u67b6&#xff08;\u8c03\u5ea6\u4e2d\u5fc3\u90e8\u5206&#xff09;<\/h3>\n<p>import socket<br \/>\nimport json<br \/>\nimport threading<br \/>\nimport time<br \/>\nimport sqlite3<br \/>\nimport queue<br \/>\nfrom typing import Dict, List, Tuple, Optional<\/p>\n<p># \u901a\u4fe1\u534f\u8bae\u5b9a\u4e49<br \/>\nclass Protocol:<br \/>\n    # \u6d88\u606f\u7c7b\u578b<br \/>\n    TYPE_TASK_SUBMIT &#061; &#034;TASK_SUBMIT&#034;    # \u63d0\u4ea4\u4efb\u52a1<br \/>\n    TYPE_TASK_ASSIGN &#061; &#034;TASK_ASSIGN&#034;    # \u5206\u914d\u4efb\u52a1<br \/>\n    TYPE_TASK_RESULT &#061; &#034;TASK_RESULT&#034;    # \u8fd4\u56de\u7ed3\u679c<br \/>\n    TYPE_WORKER_HEARTBEAT &#061; &#034;HEARTBEAT&#034; # \u5de5\u4f5c\u8282\u70b9\u5fc3\u8df3<br \/>\n    TYPE_WORKER_REGISTER &#061; &#034;REGISTER&#034;   # \u5de5\u4f5c\u8282\u70b9\u6ce8\u518c<\/p>\n<p>    &#064;staticmethod<br \/>\n    def pack_message(msg_type: str, data: dict) -&gt; bytes:<br \/>\n        &#034;&#034;&#034;\u6253\u5305\u6d88\u606f\u4e3aJSON\u683c\u5f0f&#034;&#034;&#034;<br \/>\n        message &#061; {&#034;type&#034;: msg_type, &#034;data&#034;: data, &#034;timestamp&#034;: time.time()}<br \/>\n        return json.dumps(message).encode()<\/p>\n<p>    &#064;staticmethod<br \/>\n    def unpack_message(msg: bytes) -&gt; dict:<br \/>\n        &#034;&#034;&#034;\u89e3\u6790JSON\u6d88\u606f&#034;&#034;&#034;<br \/>\n        try:<br \/>\n            return json.loads(msg.decode())<br \/>\n        except:<br \/>\n            return {&#034;type&#034;: &#034;ERROR&#034;, &#034;data&#034;: &#034;Invalid message format&#034;}<\/p>\n<p># \u4efb\u52a1\u7ba1\u7406\u7c7b<br \/>\nclass TaskManager:<br \/>\n    def __init__(self, db_path&#061;&#034;task_system.db&#034;):<br \/>\n        self.task_queue &#061; queue.PriorityQueue()  # \u4f18\u5148\u7ea7\u961f\u5217&#xff0c;\u6570\u5b57\u8d8a\u5c0f\u4f18\u5148\u7ea7\u8d8a\u9ad8<br \/>\n        self.task_status &#061; {}  # task_id: {&#034;status&#034;: &#034;&#034;, &#034;worker&#034;: &#034;&#034;, &#034;result&#034;: &#034;&#034;}<br \/>\n        self.worker_nodes &#061; {}  # worker_id: {&#034;address&#034;: &#034;&#034;, &#034;last_heartbeat&#034;: 0, &#034;busy&#034;: False}<br \/>\n        self.db_path &#061; db_path<br \/>\n        self._init_database()<\/p>\n<p>    def _init_database(self):<br \/>\n        &#034;&#034;&#034;\u521d\u59cb\u5316\u6570\u636e\u5e93&#034;&#034;&#034;<br \/>\n        conn &#061; sqlite3.connect(self.db_path)<br \/>\n        cursor &#061; conn.cursor()<br \/>\n        cursor.execute(&#039;&#039;&#039;<br \/>\n        CREATE TABLE IF NOT EXISTS tasks (<br \/>\n            task_id TEXT PRIMARY KEY,<br \/>\n            name TEXT,<br \/>\n            priority INTEGER,<br \/>\n            status TEXT,<br \/>\n            input_data TEXT,<br \/>\n            result TEXT,<br \/>\n            worker_id TEXT,<br \/>\n            create_time REAL,<br \/>\n            update_time REAL<br \/>\n        )<br \/>\n        &#039;&#039;&#039;)<br \/>\n        conn.commit()<br \/>\n        conn.close()<\/p>\n<p>    def add_task(self, task_id: str, name: str, priority: int, data: dict) -&gt; bool:<br \/>\n        &#034;&#034;&#034;\u6dfb\u52a0\u4efb\u52a1\u5230\u961f\u5217&#034;&#034;&#034;<br \/>\n        if task_id in self.task_status:<br \/>\n            return False<\/p>\n<p>        self.task_status[task_id] &#061; {<br \/>\n            &#034;status&#034;: &#034;PENDING&#034;,<br \/>\n            &#034;worker&#034;: &#034;&#034;,<br \/>\n            &#034;result&#034;: None,<br \/>\n            &#034;create_time&#034;: time.time()<br \/>\n        }<br \/>\n        self.task_queue.put((priority, task_id, name, data))<\/p>\n<p>        # \u5b58\u50a8\u5230\u6570\u636e\u5e93<br \/>\n        conn &#061; sqlite3.connect(self.db_path)<br \/>\n        cursor &#061; conn.cursor()<br \/>\n        cursor.execute(<br \/>\n            &#034;INSERT INTO tasks (task_id, name, priority, status, input_data, create_time, update_time) &#034;<br \/>\n            &#034;VALUES (?, ?, ?, ?, ?, ?, ?)&#034;,<br \/>\n            (task_id, name, priority, &#034;PENDING&#034;, json.dumps(data), time.time(), time.time())<br \/>\n        )<br \/>\n        conn.commit()<br \/>\n        conn.close()<br \/>\n        return True<\/p>\n<p>    def get_available_worker(self) -&gt; Optional[str]:<br \/>\n        &#034;&#034;&#034;\u83b7\u53d6\u53ef\u7528\u5de5\u4f5c\u8282\u70b9&#034;&#034;&#034;<br \/>\n        current_time &#061; time.time()<br \/>\n        available_workers &#061; []<\/p>\n<p>        # \u8fc7\u6ee4\u5b58\u6d3b\u4e14\u7a7a\u95f2\u7684\u8282\u70b9&#xff08;10\u79d2\u5185\u6709\u5fc3\u8df3&#xff09;<br \/>\n        for worker_id, info in self.worker_nodes.items():<br \/>\n            if (not info[&#034;busy&#034;]) and (current_time &#8211; info[&#034;last_heartbeat&#034;] &lt; 10):<br \/>\n                available_workers.append(worker_id)<\/p>\n<p>        if available_workers:<br \/>\n            # \u7b80\u5355\u8f6e\u8be2\u6216\u9009\u62e9\u8d1f\u8f7d\u6700\u4f4e\u7684\u8282\u70b9<br \/>\n            return available_workers[0]<br \/>\n        return None<\/p>\n<p>    def assign_task(self) -&gt; Optional[Tuple[str, str, dict]]:<br \/>\n        &#034;&#034;&#034;\u5206\u914d\u4efb\u52a1\u7ed9\u5de5\u4f5c\u8282\u70b9&#034;&#034;&#034;<br \/>\n        if self.task_queue.empty():<br \/>\n            return None<\/p>\n<p>        # \u83b7\u53d6\u6700\u9ad8\u4f18\u5148\u7ea7\u4efb\u52a1<br \/>\n        priority, task_id, task_name, task_data &#061; self.task_queue.get()<\/p>\n<p>        # \u68c0\u67e5\u4efb\u52a1\u72b6\u6001<br \/>\n        if self.task_status[task_id][&#034;status&#034;] !&#061; &#034;PENDING&#034;:<br \/>\n            return self.assign_task()  # \u4efb\u52a1\u72b6\u6001\u5df2\u53d8\u66f4&#xff0c;\u91cd\u65b0\u5206\u914d<\/p>\n<p>        # \u83b7\u53d6\u53ef\u7528\u5de5\u4f5c\u8282\u70b9<br \/>\n        worker_id &#061; self.get_available_worker()<br \/>\n        if not worker_id:<br \/>\n            # \u65e0\u53ef\u7528\u8282\u70b9&#xff0c;\u5c06\u4efb\u52a1\u653e\u56de\u961f\u5217<br \/>\n            self.task_queue.put((priority, task_id, task_name, task_data))<br \/>\n            return None<\/p>\n<p>        # \u66f4\u65b0\u4efb\u52a1\u72b6\u6001<br \/>\n        self.task_status[task_id] &#061; {<br \/>\n            **self.task_status[task_id],<br \/>\n            &#034;status&#034;: &#034;RUNNING&#034;,<br \/>\n            &#034;worker&#034;: worker_id,<br \/>\n            &#034;update_time&#034;: time.time()<br \/>\n        }<\/p>\n<p>        # \u66f4\u65b0\u5de5\u4f5c\u8282\u70b9\u72b6\u6001<br \/>\n        self.worker_nodes[worker_id][&#034;busy&#034;] &#061; True<\/p>\n<p>        # \u66f4\u65b0\u6570\u636e\u5e93<br \/>\n        conn &#061; sqlite3.connect(self.db_path)<br \/>\n        cursor &#061; conn.cursor()<br \/>\n        cursor.execute(<br \/>\n            &#034;UPDATE tasks SET status &#061; ?, worker_id &#061; ?, update_time &#061; ? WHERE task_id &#061; ?&#034;,<br \/>\n            (&#034;RUNNING&#034;, worker_id, time.time(), task_id)<br \/>\n        )<br \/>\n        conn.commit()<br \/>\n        conn.close()<\/p>\n<p>        return (worker_id, task_id, task_data)<\/p>\n<p>    def process_result(self, task_id: str, result: dict, worker_id: str) -&gt; bool:<br \/>\n        &#034;&#034;&#034;\u5904\u7406\u4efb\u52a1\u7ed3\u679c&#034;&#034;&#034;<br \/>\n        if task_id not in self.task_status:<br \/>\n            return False<\/p>\n<p>        # \u66f4\u65b0\u4efb\u52a1\u72b6\u6001<br \/>\n        self.task_status[task_id] &#061; {<br \/>\n            **self.task_status[task_id],<br \/>\n            &#034;status&#034;: &#034;COMPLETED&#034;,<br \/>\n            &#034;result&#034;: result,<br \/>\n            &#034;update_time&#034;: time.time()<br \/>\n        }<\/p>\n<p>        # \u91ca\u653e\u5de5\u4f5c\u8282\u70b9<br \/>\n        if worker_id in self.worker_nodes:<br \/>\n            self.worker_nodes[worker_id][&#034;busy&#034;] &#061; False<\/p>\n<p>        # \u5b58\u50a8\u7ed3\u679c\u5230\u6570\u636e\u5e93<br \/>\n        conn &#061; sqlite3.connect(self.db_path)<br \/>\n        cursor &#061; conn.cursor()<br \/>\n        cursor.execute(<br \/>\n            &#034;UPDATE tasks SET status &#061; ?, result &#061; ?, worker_id &#061; ?, update_time &#061; ? WHERE task_id &#061; ?&#034;,<br \/>\n            (&#034;COMPLETED&#034;, json.dumps(result), &#034;&#034;, time.time(), task_id)<br \/>\n        )<br \/>\n        conn.commit()<br \/>\n        conn.close()<br \/>\n        return True<\/p>\n<p>    def register_worker(self, worker_id: str, address: str) -&gt; bool:<br \/>\n        &#034;&#034;&#034;\u6ce8\u518c\u5de5\u4f5c\u8282\u70b9&#034;&#034;&#034;<br \/>\n        if worker_id in self.worker_nodes:<br \/>\n            return False<\/p>\n<p>        self.worker_nodes[worker_id] &#061; {<br \/>\n            &#034;address&#034;: address,<br \/>\n            &#034;last_heartbeat&#034;: time.time(),<br \/>\n            &#034;busy&#034;: False<br \/>\n        }<br \/>\n        return True<\/p>\n<p>    def update_heartbeat(self, worker_id: str) -&gt; bool:<br \/>\n        &#034;&#034;&#034;\u66f4\u65b0\u5de5\u4f5c\u8282\u70b9\u5fc3\u8df3&#034;&#034;&#034;<br \/>\n        if worker_id in self.worker_nodes:<br \/>\n            self.worker_nodes[worker_id][&#034;last_heartbeat&#034;] &#061; time.time()<br \/>\n            return True<br \/>\n        return False<\/p>\n<p># \u8c03\u5ea6\u4e2d\u5fc3\u670d\u52a1\u5668\u7c7b<br \/>\nclass SchedulerServer:<br \/>\n    def __init__(self, host&#061;&#034;0.0.0.0&#034;, port&#061;9999):<br \/>\n        self.host &#061; host<br \/>\n        self.port &#061; port<br \/>\n        self.task_manager &#061; TaskManager()<br \/>\n        self.server_socket &#061; socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br \/>\n        self.server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)<br \/>\n        self.running &#061; False<br \/>\n        self.clients &#061; {}  # client_id: socket<\/p>\n<p>    def start(self):<br \/>\n        &#034;&#034;&#034;\u542f\u52a8\u670d\u52a1\u5668&#034;&#034;&#034;<br \/>\n        self.server_socket.bind((self.host, self.port))<br \/>\n        self.server_socket.listen(10)<br \/>\n        self.running &#061; True<br \/>\n        print(f&#034;\u8c03\u5ea6\u4e2d\u5fc3\u542f\u52a8\u6210\u529f&#xff0c;\u76d1\u542c\u5730\u5740: {self.host}:{self.port}&#034;)<\/p>\n<p>        # \u542f\u52a8\u5fc3\u8df3\u68c0\u6d4b\u7ebf\u7a0b<br \/>\n        heartbeat_thread &#061; threading.Thread(target&#061;self._heartbeat_check, daemon&#061;True)<br \/>\n        heartbeat_thread.start()<\/p>\n<p>        # \u63a5\u53d7\u5ba2\u6237\u7aef\u8fde\u63a5<br \/>\n        while self.running:<br \/>\n            try:<br \/>\n                client_socket, address &#061; self.server_socket.accept()<br \/>\n                print(f&#034;\u65b0\u8fde\u63a5: {address}&#034;)<br \/>\n                client_thread &#061; threading.Thread(<br \/>\n                    target&#061;self._handle_client,<br \/>\n                    args&#061;(client_socket, address),<br \/>\n                    daemon&#061;True<br \/>\n                )<br \/>\n                client_thread.start()<br \/>\n            except Exception as e:<br \/>\n                print(f&#034;\u63a5\u53d7\u8fde\u63a5\u5931\u8d25: {e}&#034;)<br \/>\n                if self.running:<br \/>\n                    time.sleep(1)<\/p>\n<p>    def _handle_client(self, client_socket: socket.socket, address: tuple):<br \/>\n        &#034;&#034;&#034;\u5904\u7406\u5ba2\u6237\u7aef\u8fde\u63a5&#034;&#034;&#034;<br \/>\n        client_id &#061; f&#034;{address[0]}:{address[1]}&#034;<br \/>\n        self.clients[client_id] &#061; client_socket<\/p>\n<p>        try:<br \/>\n            while True:<br \/>\n                # \u63a5\u6536\u6d88\u606f<br \/>\n                data &#061; client_socket.recv(4096)<br \/>\n                if not data:<br \/>\n                    break<\/p>\n<p>                # \u89e3\u6790\u6d88\u606f<br \/>\n                message &#061; Protocol.unpack_message(data)<br \/>\n                msg_type &#061; message.get(&#034;type&#034;, &#034;UNKNOWN&#034;)<br \/>\n                msg_data &#061; message.get(&#034;data&#034;, {})<br \/>\n                print(f&#034;\u6536\u5230\u6d88\u606f [{client_id}]: {msg_type}&#034;)<\/p>\n<p>                # \u5904\u7406\u4e0d\u540c\u7c7b\u578b\u6d88\u606f<br \/>\n                if msg_type &#061;&#061; Protocol.TYPE_WORKER_REGISTER:<br \/>\n                    worker_id &#061; msg_data.get(&#034;worker_id&#034;)<br \/>\n                    if self.task_manager.register_worker(worker_id, client_id):<br \/>\n                        response &#061; Protocol.pack_message(<br \/>\n                            &#034;REGISTER_SUCCESS&#034;,<br \/>\n                            {&#034;message&#034;: &#034;Worker registered successfully&#034;}<br \/>\n                        )<br \/>\n                    else:<br \/>\n                        response &#061; Protocol.pack_message(<br \/>\n                            &#034;REGISTER_FAILED&#034;,<br \/>\n                            {&#034;message&#034;: &#034;Worker ID already exists&#034;}<br \/>\n                        )<br \/>\n                    client_socket.send(response)<\/p>\n<p>                elif msg_type &#061;&#061; Protocol.TYPE_WORKER_HEARTBEAT:<br \/>\n                    worker_id &#061; msg_data.get(&#034;worker_id&#034;)<br \/>\n                    if self.task_manager.update_heartbeat(worker_id):<br \/>\n                        # \u5c1d\u8bd5\u5206\u914d\u4efb\u52a1<br \/>\n                        task &#061; self.task_manager.assign_task()<br \/>\n                        if task:<br \/>\n                            worker_id, task_id, task_data &#061; task<br \/>\n                            response &#061; Protocol.pack_message(<br \/>\n                                Protocol.TYPE_TASK_ASSIGN,<br \/>\n                                {&#034;task_id&#034;: task_id, &#034;data&#034;: task_data}<br \/>\n                            )<br \/>\n                        else:<br \/>\n                            response &#061; Protocol.pack_message(<br \/>\n                                &#034;NO_TASK_ASSIGN&#034;,<br \/>\n                                {&#034;message&#034;: &#034;No task available&#034;}<br \/>\n                            )<br \/>\n                    else:<br \/>\n                        response &#061; Protocol.pack_message(<br \/>\n                            &#034;HEARTBEAT_FAILED&#034;,<br \/>\n                            {&#034;message&#034;: &#034;Worker not registered&#034;}<br \/>\n                        )<br \/>\n                    client_socket.send(response)<\/p>\n<p>                elif msg_type &#061;&#061; Protocol.TYPE_TASK_SUBMIT:<br \/>\n                    task_id &#061; msg_data.get(&#034;task_id&#034;)<br \/>\n                    task_name &#061; msg_data.get(&#034;task_name&#034;, &#034;Unknown Task&#034;)<br \/>\n                    priority &#061; msg_data.get(&#034;priority&#034;, 5)  # \u9ed8\u8ba4\u4e3a\u4e2d\u7b49\u4f18\u5148\u7ea7<br \/>\n                    task_data &#061; msg_data.get(&#034;data&#034;, {})<\/p>\n<p>                    if self.task_manager.add_task(task_id, task_name, priority, task_data):<br \/>\n                        response &#061; Protocol.pack_message(<br \/>\n                            &#034;TASK_SUBMIT_SUCCESS&#034;,<br \/>\n                            {&#034;task_id&#034;: task_id, &#034;message&#034;: &#034;Task submitted&#034;}<br \/>\n                        )<br \/>\n                    else:<br \/>\n                        response &#061; Protocol.pack_message(<br \/>\n                            &#034;TASK_SUBMIT_FAILED&#034;,<br \/>\n                            {&#034;message&#034;: &#034;Task ID already exists&#034;}<br \/>\n                        )<br \/>\n                    client_socket.send(response)<\/p>\n<p>                elif msg_type &#061;&#061; Protocol.TYPE_TASK_RESULT:<br \/>\n                    task_id &#061; msg_data.get(&#034;task_id&#034;)<br \/>\n                    result &#061; msg_data.get(&#034;result&#034;, {})<br \/>\n                    worker_id &#061; msg_data.get(&#034;worker_id&#034;)<\/p>\n<p>                    if self.task_manager.process_result(task_id, result, worker_id):<br \/>\n                        response &#061; Protocol.pack_message(<br \/>\n                            &#034;RESULT_RECEIVED&#034;,<br \/>\n                            {&#034;task_id&#034;: task_id, &#034;message&#034;: &#034;Result received&#034;}<br \/>\n                        )<br \/>\n                    else:<br \/>\n                        response &#061; Protocol.pack_message(<br \/>\n                            &#034;RESULT_FAILED&#034;,<br \/>\n                            {&#034;message&#034;: &#034;Invalid task ID&#034;}<br \/>\n                        )<br \/>\n                    client_socket.send(response)<\/p>\n<p>                else:<br \/>\n                    response &#061; Protocol.pack_message(<br \/>\n                        &#034;UNKNOWN_MESSAGE&#034;,<br \/>\n                        {&#034;message&#034;: &#034;Unknown message type&#034;}<br \/>\n                    )<br \/>\n                    client_socket.send(response)<\/p>\n<p>        except Exception as e:<br \/>\n            print(f&#034;\u5ba2\u6237\u7aef\u5904\u7406\u9519\u8bef [{client_id}]: {e}&#034;)<br \/>\n        finally:<br \/>\n            if client_id in self.clients:<br \/>\n                del self.clients[client_id]<br \/>\n            client_socket.close()<br \/>\n            print(f&#034;\u8fde\u63a5\u5173\u95ed: {client_id}&#034;)<\/p>\n<p>    def _heartbeat_check(self):<br \/>\n        &#034;&#034;&#034;\u5b9a\u671f\u68c0\u67e5\u5de5\u4f5c\u8282\u70b9\u5fc3\u8df3&#034;&#034;&#034;<br \/>\n        while self.running:<br \/>\n            current_time &#061; time.time()<br \/>\n            for worker_id, info in list(self.worker_nodes.items()):<br \/>\n                if current_time &#8211; info[&#034;last_heartbeat&#034;] &gt; 30:<br \/>\n                    # \u8282\u70b9\u8d85\u65f6&#xff0c;\u6807\u8bb0\u4e3a\u79bb\u7ebf<br \/>\n                    print(f&#034;\u5de5\u4f5c\u8282\u70b9 {worker_id} \u8d85\u65f6&#xff0c;\u6807\u8bb0\u4e3a\u79bb\u7ebf&#034;)<br \/>\n                    info[&#034;busy&#034;] &#061; False  # \u91ca\u653e\u53ef\u80fd\u6b63\u5728\u5904\u7406\u7684\u4efb\u52a1<br \/>\n            time.sleep(10)  # \u6bcf10\u79d2\u68c0\u67e5\u4e00\u6b21<\/p>\n<p>    def stop(self):<br \/>\n        &#034;&#034;&#034;\u505c\u6b62\u670d\u52a1\u5668&#034;&#034;&#034;<br \/>\n        self.running &#061; False<br \/>\n        if self.server_socket:<br \/>\n            self.server_socket.close()<br \/>\n        print(&#034;\u8c03\u5ea6\u4e2d\u5fc3\u5df2\u505c\u6b62&#034;)<\/p>\n<p># \u4f7f\u7528\u793a\u4f8b<br \/>\nif __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    server &#061; SchedulerServer(port&#061;9999)<br \/>\n    try:<br \/>\n        server.start()<br \/>\n    except KeyboardInterrupt:<br \/>\n        print(&#034;\u63a5\u6536\u5230\u505c\u6b62\u4fe1\u53f7&#034;)<br \/>\n    finally:<br \/>\n        server.stop()<\/p>\n<h3 id=\"%E9%9A%BE%E7%82%B9%E5%88%86%E6%9E%90\">\u96be\u70b9\u5206\u6790<\/h3>\n<ul>\n<li>\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e00\u81f4\u6027&#xff1a;\u591a\u4e2a\u5de5\u4f5c\u8282\u70b9\u548c\u5ba2\u6237\u7aef\u540c\u65f6\u64cd\u4f5c\u65f6\u786e\u4fdd\u6570\u636e\u4e00\u81f4\u6027<\/li>\n<li>\u7f51\u7edc\u901a\u4fe1\u53ef\u9760\u6027&#xff1a;\u5904\u7406\u7f51\u7edc\u5ef6\u8fdf\u3001\u65ad\u5f00\u91cd\u8fde\u3001\u6d88\u606f\u4e22\u5931\u7b49\u95ee\u9898<\/li>\n<li>\u4efb\u52a1\u4f18\u5148\u7ea7\u8c03\u5ea6&#xff1a;\u5b9e\u73b0\u516c\u5e73\u4e14\u9ad8\u6548\u7684\u4efb\u52a1\u5206\u914d\u7b97\u6cd5<\/li>\n<li>\u7cfb\u7edf\u76d1\u63a7\u4e0e\u5bb9\u9519&#xff1a;\u8bbe\u8ba1\u5b8c\u5584\u7684\u76d1\u63a7\u673a\u5236\u548c\u6545\u969c\u6062\u590d\u7b56\u7565<\/li>\n<li>\u6027\u80fd\u4f18\u5316&#xff1a;\u5904\u7406\u5927\u91cf\u4efb\u52a1\u65f6\u7684\u5e76\u53d1\u6027\u80fd\u74f6\u9888&#xff08;\u5982\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u3001\u5f02\u6b65 IO&#xff09;<\/li>\n<\/ul>\n<h3 id=\"%E6%89%A9%E5%B1%95%E6%96%B9%E5%90%91\">\u6269\u5c55\u65b9\u5411<\/h3>\n<ul>\n<li>\u6dfb\u52a0 Web \u7ba1\u7406\u754c\u9762&#xff08;\u4f7f\u7528 Flask\/Django&#xff09;<\/li>\n<li>\u96c6\u6210 Redis \u4f5c\u4e3a\u5206\u5e03\u5f0f\u6d88\u606f\u961f\u5217<\/li>\n<li>\u652f\u6301\u4efb\u52a1\u4f9d\u8d56\u5173\u7cfb&#xff08;DAG \u4efb\u52a1\u6d41&#xff09;<\/li>\n<li>\u5b9e\u73b0\u8d44\u6e90\u76d1\u63a7&#xff08;CPU \/ \u5185\u5b58 \/ \u78c1\u76d8&#xff09;<\/li>\n<li>\u589e\u52a0\u4efb\u52a1\u91cd\u8bd5\u548c\u5931\u8d25\u8f6c\u79fb\u673a\u5236<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb243\u6b21\uff0c\u70b9\u8d5e3\u6b21\uff0c\u6536\u85cf3\u6b21\u3002\u5206\u5e03\u5f0f\u4efb\u52a1\u8c03\u5ea6\u7cfb\u7edf\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,664,4125,190],"topic":[],"class_list":["post-44313","post","type-post","status-publish","format-standard","hentry","category-server","tag-python","tag-664","tag-4125","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python\u5b9e\u4f8b\u9898\uff1a\u5206\u5e03\u5f0f\u4efb\u52a1\u8c03\u5ea6\u7cfb\u7edf - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/44313.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python\u5b9e\u4f8b\u9898\uff1a\u5206\u5e03\u5f0f\u4efb\u52a1\u8c03\u5ea6\u7cfb\u7edf - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb243\u6b21\uff0c\u70b9\u8d5e3\u6b21\uff0c\u6536\u85cf3\u6b21\u3002\u5206\u5e03\u5f0f\u4efb\u52a1\u8c03\u5ea6\u7cfb\u7edf\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/44313.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-18T01:34:28+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/44313.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/44313.html\",\"name\":\"Python\u5b9e\u4f8b\u9898\uff1a\u5206\u5e03\u5f0f\u4efb\u52a1\u8c03\u5ea6\u7cfb\u7edf - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-06-18T01:34:28+00:00\",\"dateModified\":\"2025-06-18T01:34:28+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/44313.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/44313.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/44313.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\u5b9e\u4f8b\u9898\uff1a\u5206\u5e03\u5f0f\u4efb\u52a1\u8c03\u5ea6\u7cfb\u7edf\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python\u5b9e\u4f8b\u9898\uff1a\u5206\u5e03\u5f0f\u4efb\u52a1\u8c03\u5ea6\u7cfb\u7edf - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/44313.html","og_locale":"zh_CN","og_type":"article","og_title":"Python\u5b9e\u4f8b\u9898\uff1a\u5206\u5e03\u5f0f\u4efb\u52a1\u8c03\u5ea6\u7cfb\u7edf - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb243\u6b21\uff0c\u70b9\u8d5e3\u6b21\uff0c\u6536\u85cf3\u6b21\u3002\u5206\u5e03\u5f0f\u4efb\u52a1\u8c03\u5ea6\u7cfb\u7edf\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/44313.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-06-18T01:34:28+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/44313.html","url":"https:\/\/www.wsisp.com\/helps\/44313.html","name":"Python\u5b9e\u4f8b\u9898\uff1a\u5206\u5e03\u5f0f\u4efb\u52a1\u8c03\u5ea6\u7cfb\u7edf - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-06-18T01:34:28+00:00","dateModified":"2025-06-18T01:34:28+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/44313.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/44313.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/44313.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Python\u5b9e\u4f8b\u9898\uff1a\u5206\u5e03\u5f0f\u4efb\u52a1\u8c03\u5ea6\u7cfb\u7edf"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/44313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=44313"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/44313\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=44313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=44313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=44313"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=44313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}