ruff format
This commit is contained in:
parent
e7e8ec3bfd
commit
c51787c987
4 changed files with 11 additions and 6 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import redis
|
import redis
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
|
|
||||||
class RedisAdapter:
|
class RedisAdapter:
|
||||||
def __init__(self, host, port, lock_name):
|
def __init__(self, host, port, lock_name):
|
||||||
self.redis = redis.Redis(host=host, port=port)
|
self.redis = redis.Redis(host=host, port=port)
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,4 @@ async def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
||||||
|
|
|
||||||
|
|
@ -6,24 +6,26 @@ import subprocess
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("=== Kuzu Subprocess Lock Test ===")
|
print("=== Kuzu Subprocess Lock Test ===")
|
||||||
print("Starting writer and reader in separate subprocesses...")
|
print("Starting writer and reader in separate subprocesses...")
|
||||||
print("Writer will hold the database lock, reader should block or fail\n")
|
print("Writer will hold the database lock, reader should block or fail\n")
|
||||||
|
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
|
||||||
# Start writer subprocess
|
# Start writer subprocess
|
||||||
writer_process = subprocess.Popen([os.sys.executable, "writer.py"])
|
writer_process = subprocess.Popen([os.sys.executable, "writer.py"])
|
||||||
|
|
||||||
reader_process = subprocess.Popen([os.sys.executable, "reader.py"])
|
reader_process = subprocess.Popen([os.sys.executable, "reader.py"])
|
||||||
|
|
||||||
# Wait for both processes to complete
|
# Wait for both processes to complete
|
||||||
writer_process.wait()
|
writer_process.wait()
|
||||||
reader_process.wait()
|
reader_process.wait()
|
||||||
|
|
||||||
total_time = time.time() - start_time
|
total_time = time.time() - start_time
|
||||||
print(f"\nTotal execution time: {total_time:.2f}s")
|
print(f"\nTotal execution time: {total_time:.2f}s")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ def create_node(name):
|
||||||
)
|
)
|
||||||
return document
|
return document
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
adapter = KuzuAdapter("test.db")
|
adapter = KuzuAdapter("test.db")
|
||||||
nodes = [create_node(f"Node{i}") for i in range(200000)]
|
nodes = [create_node(f"Node{i}") for i in range(200000)]
|
||||||
|
|
@ -28,5 +29,6 @@ async def main():
|
||||||
|
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
asyncio.run(main())
|
asyncio.run(main())
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue