chore: adds error reproduction files (to delete later)
This commit is contained in:
parent
0776a07f0a
commit
d537d6225c
3 changed files with 89 additions and 0 deletions
29
working_dir_error_replication/reader.py
Normal file
29
working_dir_error_replication/reader.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import asyncio
|
||||
import time
|
||||
from cognee.infrastructure.databases.graph.kuzu.adapter import KuzuAdapter
|
||||
|
||||
# This will create the test.db if it doesn't exist
|
||||
|
||||
|
||||
async def main():
|
||||
print("Reader: Waiting 2 seconds...")
|
||||
|
||||
time.sleep(5)
|
||||
adapter = KuzuAdapter("test.db")
|
||||
result = await adapter.query("MATCH (n:Node) RETURN COUNT(n)")
|
||||
|
||||
print(f"Reader: Found {result[0][0]} nodes")
|
||||
result = await adapter.query("MATCH (n:Node) RETURN COUNT(n)")
|
||||
print(f"Reader: Found {result[0][0]} nodes")
|
||||
result = await adapter.query("MATCH (n:Node) RETURN COUNT(n)")
|
||||
print(f"Reader: Found {result[0][0]} nodes")
|
||||
result = await adapter.query("MATCH (n:Node) RETURN COUNT(n)")
|
||||
print(f"Reader: Found {result[0][0]} nodes")
|
||||
result = await adapter.query("MATCH (n:Node) RETURN COUNT(n)")
|
||||
print(f"Reader: Found {result} nodes")
|
||||
result = await adapter.query("MATCH (n:Node) RETURN COUNT(n)")
|
||||
print(f"Reader: Found {result[0][0]} nodes")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
29
working_dir_error_replication/run_subprocess_test.py
Normal file
29
working_dir_error_replication/run_subprocess_test.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
"""
|
||||
Run writer and reader in separate subprocesses to test Kuzu locks.
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
import time
|
||||
import os
|
||||
|
||||
def main():
|
||||
print("=== Kuzu Subprocess Lock Test ===")
|
||||
print("Starting writer and reader in separate subprocesses...")
|
||||
print("Writer will hold the database lock, reader should block or fail\n")
|
||||
|
||||
start_time = time.time()
|
||||
|
||||
# Start writer subprocess
|
||||
writer_process = subprocess.Popen([os.sys.executable, "writer.py"])
|
||||
|
||||
reader_process = subprocess.Popen([os.sys.executable, "reader.py"])
|
||||
|
||||
# Wait for both processes to complete
|
||||
writer_process.wait()
|
||||
reader_process.wait()
|
||||
|
||||
total_time = time.time() - start_time
|
||||
print(f"\nTotal execution time: {total_time:.2f}s")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
31
working_dir_error_replication/writer.py
Normal file
31
working_dir_error_replication/writer.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import asyncio
|
||||
from uuid import uuid4
|
||||
from cognee.infrastructure.databases.graph.kuzu.adapter import KuzuAdapter
|
||||
import time
|
||||
import uuid
|
||||
from cognee.modules.chunking.models.DocumentChunk import DocumentChunk
|
||||
from cognee.modules.data.processing.document_types import PdfDocument
|
||||
|
||||
|
||||
def create_node(name):
|
||||
document = PdfDocument(
|
||||
id=uuid.uuid4(),
|
||||
name=name,
|
||||
raw_data_location=name,
|
||||
external_metadata="",
|
||||
mime_type="",
|
||||
)
|
||||
return document
|
||||
|
||||
async def main():
|
||||
adapter = KuzuAdapter("test.db")
|
||||
print("Writer: Starting...")
|
||||
nodes = [create_node(f"Node{i}") for i in range(100)]
|
||||
await adapter.add_nodes(nodes)
|
||||
|
||||
print("writer finished...")
|
||||
|
||||
time.sleep(100)
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Loading…
Add table
Reference in a new issue