mirror of
https://github.com/langgenius/dify.git
synced 2026-05-13 08:57:28 +08:00
feat: switch async
This commit is contained in:
parent
c3b4029d0b
commit
3058415b4e
@ -113,10 +113,21 @@ class SandboxBuilder:
|
|||||||
assets_id=self._assets_id,
|
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.
|
# Run sandbox setup asynchronously so workflow execution can proceed.
|
||||||
def initialize() -> None:
|
def initialize() -> None:
|
||||||
try:
|
try:
|
||||||
for init in self._initializers:
|
for init in self._initializers:
|
||||||
|
if not init.async_initialize():
|
||||||
|
continue
|
||||||
|
|
||||||
if sandbox.is_cancelled():
|
if sandbox.is_cancelled():
|
||||||
return
|
return
|
||||||
init.initialize(sandbox)
|
init.initialize(sandbox)
|
||||||
|
|||||||
@ -6,3 +6,9 @@ from core.sandbox.sandbox import Sandbox
|
|||||||
class SandboxInitializer(ABC):
|
class SandboxInitializer(ABC):
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def initialize(self, env: Sandbox) -> None: ...
|
def initialize(self, env: Sandbox) -> None: ...
|
||||||
|
|
||||||
|
def async_initialize(self) -> bool:
|
||||||
|
"""
|
||||||
|
Whether the initializer needs to run asynchronously.
|
||||||
|
"""
|
||||||
|
return False
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user