镜像自地址
https://github.com/binary-husky/gpt_academic.git
已同步 2025-12-07 23:16:48 +00:00
version 3.6
这个提交包含在:
24
request_llms/queued_pipe.py
普通文件
24
request_llms/queued_pipe.py
普通文件
@@ -0,0 +1,24 @@
|
||||
from multiprocessing import Pipe, Queue
|
||||
import time
|
||||
import threading
|
||||
|
||||
class PipeSide(object):
|
||||
def __init__(self, q_2remote, q_2local) -> None:
|
||||
self.q_2remote = q_2remote
|
||||
self.q_2local = q_2local
|
||||
|
||||
def recv(self):
|
||||
return self.q_2local.get()
|
||||
|
||||
def send(self, buf):
|
||||
self.q_2remote.put(buf)
|
||||
|
||||
def poll(self):
|
||||
return not self.q_2local.empty()
|
||||
|
||||
def create_queue_pipe():
|
||||
q_p2c = Queue()
|
||||
q_c2p = Queue()
|
||||
pipe_c = PipeSide(q_2local=q_p2c, q_2remote=q_c2p)
|
||||
pipe_p = PipeSide(q_2local=q_c2p, q_2remote=q_p2c)
|
||||
return pipe_c, pipe_p
|
||||
在新工单中引用
屏蔽一个用户