"vllm/vscode:/vscode.git/clone" did not exist on "3efb9f4d95bfe8810b106637cd9eb45693c93e4d"
forward_context.py 733 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35



import threading

_forward_context_left = None
_forward_context_right = None

_left_tid = 0
_right_tid = 0

def init_tbo_forward_context(left_flag, tid):
    global _left_tid
    global _right_tid
    if left_flag:
        _left_tid = tid
    else:
        _right_tid = tid

def set_tbo_forward_context(_forward_context):
    global _forward_context_left
    global _forward_context_right
    tid = threading.get_ident()
    if tid == _left_tid:
        _forward_context_left = _forward_context
    else:
        _forward_context_right = _forward_context


def get_tbo_forward_context():
    tid = threading.get_ident()
    if tid == _left_tid:
        return _forward_context_left
    else:
        return _forward_context_right