mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
feat: refactor initializers to support async and sync execution
This commit is contained in:
@ -5,10 +5,12 @@ from core.sandbox.sandbox import Sandbox
|
||||
|
||||
class SandboxInitializer(ABC):
|
||||
@abstractmethod
|
||||
def initialize(self, env: Sandbox) -> None: ...
|
||||
def initialize(self, sandbox: Sandbox) -> None: ...
|
||||
|
||||
def async_initialize(self) -> bool:
|
||||
"""
|
||||
Whether the initializer needs to run asynchronously.
|
||||
"""
|
||||
return False
|
||||
|
||||
class SyncSandboxInitializer(SandboxInitializer):
|
||||
"""Marker class for initializers that must run before async setup."""
|
||||
|
||||
|
||||
class AsyncSandboxInitializer(SandboxInitializer):
|
||||
"""Marker class for initializers that can run in the background."""
|
||||
|
||||
Reference in New Issue
Block a user