fix: handle EventLoopBlockError in CI to fix non-deterministic test failures (#8890)

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
fix: fixes auth check for auto_login  (#8796)
This commit is contained in:
Jordan Frazier 2025-07-07 06:30:26 -07:00 • committed by Gabriel Luiz Freitas Almeida
commit 15f2177c90
6 changed files with 949 additions and 658 deletions

View file

@ -18,12 +18,7 @@ DEFAULT_TIMEOUT = 30
DEFAULT_MAX_DEPTH = 1
DEFAULT_FORMAT = "Text"
URL_REGEX = re.compile(
r"^(https?:\/\/)?"
r"(www\.)?"
r"([a-zA-Z0-9.-]+)"
r"(\.[a-zA-Z]{2,})?"
r"(:\d+)?"
r"(\/[^\s]*)?$",
r"^(https?:\/\/)?" r"(www\.)?" r"([a-zA-Z0-9.-]+)" r"(\.[a-zA-Z]{2,})?" r"(:\d+)?" r"(\/[^\s]*)?$",
re.IGNORECASE,
)
@ -247,14 +242,14 @@ class URLComponent(Component):
"""
try:
urls = list({self.ensure_url(url) for url in self.urls if url.strip()})
logger.info(f"URLs: {urls}")
logger.debug(f"URLs: {urls}")
if not urls:
msg = "No valid URLs provided."
raise ValueError(msg)
all_docs = []
for url in urls:
logger.info(f"Loading documents from {url}")
logger.debug(f"Loading documents from {url}")
try:
loader = self._create_loader(url)
@ -264,7 +259,7 @@ class URLComponent(Component):
logger.warning(f"No documents found for {url}")
continue
logger.info(f"Found {len(docs)} documents from {url}")
logger.debug(f"Found {len(docs)} documents from {url}")
all_docs.extend(docs)
except requests.exceptions.RequestException as e:

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -21,8 +21,22 @@ else:
def run_until_complete(coro):
try:
loop = asyncio.get_running_loop()
asyncio.get_running_loop()
except RuntimeError:
# If there's no event loop, create a new one and run the coroutine
return asyncio.run(coro)
return loop.run_until_complete(coro)
# If there's already a running event loop, we can't call run_until_complete on it
# Instead, we need to run the coroutine in a new thread with a new event loop
import concurrent.futures
def run_in_new_loop():
new_loop = asyncio.new_event_loop()
asyncio.set_event_loop(new_loop)
try:
return new_loop.run_until_complete(coro)
finally:
new_loop.close()
with concurrent.futures.ThreadPoolExecutor() as executor:
future = executor.submit(run_in_new_loop)
return future.result()