Skip to content

Commit

Permalink
Apply nest_asyncio to enable asyncio event loop nesting in process.py (
Browse files Browse the repository at this point in the history
…#1784)

* Apply nest_asyncio to enable asyncio event loop nesting in process.py

* Apply nest_asyncio to enable asyncio event loop nesting in load.py

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <[email protected]>
  • Loading branch information
rodrigosnader and ogabrielluiz authored Apr 27, 2024
1 parent 082c02f commit 02b68da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/backend/base/langflow/processing/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from typing import List, Optional, Union

from dotenv import load_dotenv
from loguru import logger

from langflow.graph import Graph
from langflow.graph.schema import RunOutputs
from langflow.processing.process import process_tweaks, run_graph
Expand Down Expand Up @@ -101,6 +103,12 @@ def run_flow_from_json(
List[RunOutputs]: A list of RunOutputs objects representing the results of running the flow.
"""
# Set all streaming to false
try:
import nest_asyncio

nest_asyncio.apply()
except Exception as e:
logger.warning(f"Could not apply nest_asyncio: {e}")
if tweaks is None:
tweaks = {}
tweaks["stream"] = False
Expand Down
2 changes: 2 additions & 0 deletions src/backend/base/langflow/processing/process.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union


from langchain.agents import AgentExecutor
from langchain.schema import AgentAction
from loguru import logger
Expand All @@ -13,6 +14,7 @@
from langflow.schema.schema import INPUT_FIELD_NAME
from langflow.services.session.service import SessionService


if TYPE_CHECKING:
from langflow.api.v1.schemas import InputValueRequest

Expand Down

0 comments on commit 02b68da

Please sign in to comment.