mirror of
https://github.com/LiteyukiStudio/croterline.git
synced 2026-01-26 05:32:16 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d5dd67b31d | |||
| 1bf1380b63 | |||
| 5d505d1c89 | |||
| 9c50844195 |
@@ -5,6 +5,11 @@ from magicoca.chan import Chan
|
||||
|
||||
class Context:
|
||||
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.sub_chan: Chan[Any] = Chan[Any]() # sub to main
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from multiprocessing import Process as _Process
|
||||
from typing import Callable, Any
|
||||
|
||||
from mypy.nodes import TypeAlias
|
||||
from typing import TypeAlias
|
||||
|
||||
from croterline.context import Context
|
||||
from croterline.utils import IsMainProcess
|
||||
@@ -13,7 +13,12 @@ _current_ctx: "Context | None" = None # 注入当前进程上下文
|
||||
|
||||
class SubProcess:
|
||||
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.func = func
|
||||
@@ -51,8 +56,6 @@ def get_ctx() -> Context | None:
|
||||
|
||||
|
||||
def _wrapper(func: ProcessFuncType, ctx: Context, *args, **kwargs):
|
||||
print("args", args)
|
||||
print("kwargs", kwargs)
|
||||
global _current_ctx
|
||||
|
||||
_current_ctx = ctx
|
||||
|
||||
Reference in New Issue
Block a user