Skip to content

[Bug]: Type error in Utils.py #1106

@LorenDH

Description

@LorenDH

Do you need to file an issue?

  • I have searched the existing issues and this bug is not already filed.
  • I believe this is a legitimate bug, not just a question or feature request.

Describe the bug

LightRAG is not finishing cleanly. Producing a Type error. See error below:
Exception ignored in: <function LightRAG.del at 0x000001BE034E6FC0>
Traceback (most recent call last):
File "c:\Users\lkden\OneDrive\Documents\GitHub\pythonLearning\lightrag2-env\Lib\site-packages\lightrag\lightrag.py", line 433, in del
File "c:\Users\lkden\OneDrive\Documents\GitHub\pythonLearning\lightrag2-env\Lib\site-packages\lightrag\lightrag.py", line 438, in _run_async_safely
File "c:\Users\lkden\OneDrive\Documents\GitHub\pythonLearning\lightrag2-env\Lib\site-packages\lightrag\utils.py", line 863, in always_get_an_event_loop
TypeError: 'NoneType' object is not callable

Steps to reproduce

Using Python 3.12.6
LightRAG 1.2.5
Run the demo code in the Readme.txt file. When everything is done and the Python script is finishing, then the error is shown. This is also happening when using setting up LightRAG to be "served" in a Python web server.

Expected Behavior

Close and finish cleanly and quietly.

LightRAG Config Used

Paste your config here

async def llm_model_func(prompt, system_prompt=None, history_messages=[], keyword_extraction=False, **kwargs) -> str:
return await openai_complete_if_cache(
"gpt-4o",
prompt,
system_prompt=system_prompt,
history_messages=history_messages,
base_url=BASE_URL,
api_key=API_KEY,
**kwargs,
)

async def embedding_func(texts: list[str]) -> np.ndarray:
return await openai_embed(
texts,
model="text-embedding-3-small",
base_url=BASE_URL,
api_key=API_KEY,
)

async def ragInit():
#embedding_dimension = await get_embedding_dim()

rag = LightRAG(
    working_dir=WORKING_DIR,
    llm_model_func=llm_model_func,
    embedding_func=EmbeddingFunc(
        embedding_dim=1536,
        max_token_size=8192,
        func=embedding_func,
    ),
)

Logs and screenshots

No response

Additional Information

  • LightRAG Version: 1.2.5
  • Operating System: Windows 11
  • Python Version: 3.12.6
  • Related Issues: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions