ref: Remove some get_event_loop calls (#4366)

Remove some get_event_loop calls
This commit is contained in:
Christophe Bornet 2024-11-02 23:04:16 +01:00 committed by GitHub
commit 35e2487acb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 33 additions and 62 deletions

File diff suppressed because one or more lines are too long

View file

@ -115,7 +115,7 @@ class TestEventManager:
assert manager.events["on_test_event"].func.__name__ == "send_event"
# Ensuring thread-safety when accessing the events dictionary
def test_thread_safety_accessing_events_dictionary(self):
async def test_thread_safety_accessing_events_dictionary(self):
def mock_callback(event_type: str, data: LoggableType):
pass
@ -130,8 +130,7 @@ class TestEventManager:
queue = asyncio.Queue()
manager = EventManager(queue)
tasks = [register_events(manager), access_events(manager)]
asyncio.get_event_loop().run_until_complete(asyncio.gather(*tasks))
await asyncio.gather(register_events(manager), access_events(manager))
# Checking the performance impact of frequent event registrations
def test_performance_impact_frequent_registrations(self):

View file

@ -2,19 +2,9 @@ from langchain_core.prompts.chat import ChatPromptTemplate
from langflow.schema.message import Message
async def test_message_async_prompt_serialization():
template = "Hello, {name}!"
message = await Message.from_template_and_variables(template, name="Langflow")
assert message.text == "Hello, Langflow!"
prompt = message.load_lc_prompt()
assert isinstance(prompt, ChatPromptTemplate)
assert prompt.messages[0].content == "Hello, Langflow!"
def test_message_prompt_serialization():
template = "Hello, {name}!"
message = Message.sync_from_template_and_variables(template, name="Langflow")
message = Message.from_template_and_variables(template, name="Langflow")
assert message.text == "Hello, Langflow!"
prompt = message.load_lc_prompt()