🐛 fix uninit ctx

This commit is contained in:
远野千束 2024-10-14 23:26:48 +08:00
parent 9c50844195
commit 5d505d1c89
2 changed files with 6 additions and 1 deletions

View File

@ -5,6 +5,11 @@ from magicoca.chan import Chan
class Context: class Context:
def __init__(self): def __init__(self):
"""
main_chan: Chan[Any] = main to sub
sub_chan: Chan[Any] = sub to main
哪个进程发送用哪个
"""
self.main_chan: Chan[Any] = Chan[Any]() # main to sub self.main_chan: Chan[Any] = Chan[Any]() # main to sub
self.sub_chan: Chan[Any] = Chan[Any]() # sub to main self.sub_chan: Chan[Any] = Chan[Any]() # sub to main

View File

@ -13,7 +13,7 @@ _current_ctx: "Context | None" = None # 注入当前进程上下文
class SubProcess: class SubProcess:
def __init__( def __init__(
self, name: str, func: ProcessFuncType, ctx: Context = Context, *args, **kwargs self, name: str, func: ProcessFuncType, ctx: Context = Context(), *args, **kwargs
): ):
self.name = name self.name = name
self.func = func self.func = func