mirror of
https://github.com/langgenius/dify.git
synced 2026-02-13 07:01:23 -05:00
feat: switch async
This commit is contained in:
@@ -113,10 +113,21 @@ class SandboxBuilder:
|
||||
assets_id=self._assets_id,
|
||||
)
|
||||
|
||||
"""
|
||||
# Run synchronous initializers before marking sandbox as ready.
|
||||
"""
|
||||
for init in self._initializers:
|
||||
if init.async_initialize():
|
||||
continue
|
||||
init.initialize(sandbox)
|
||||
|
||||
# Run sandbox setup asynchronously so workflow execution can proceed.
|
||||
def initialize() -> None:
|
||||
try:
|
||||
for init in self._initializers:
|
||||
if not init.async_initialize():
|
||||
continue
|
||||
|
||||
if sandbox.is_cancelled():
|
||||
return
|
||||
init.initialize(sandbox)
|
||||
|
||||
@@ -6,3 +6,9 @@ from core.sandbox.sandbox import Sandbox
|
||||
class SandboxInitializer(ABC):
|
||||
@abstractmethod
|
||||
def initialize(self, env: Sandbox) -> None: ...
|
||||
|
||||
def async_initialize(self) -> bool:
|
||||
"""
|
||||
Whether the initializer needs to run asynchronously.
|
||||
"""
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user