Skip to content

Commit 4b59c7a

Browse files
author
Ismail Mehdi
committed
resource leaks
1 parent 37c96c5 commit 4b59c7a

5 files changed

Lines changed: 12 additions & 7 deletions

File tree

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ container:
3636
$(CONTAINER_ENGINE) run --rm --net=host --name=evalbench_container \
3737
-v ~/.config/gcloud:/root/.config/gcloud \
3838
-e GOOGLE_CLOUD_PROJECT=cloud-db-nl2sql \
39+
--cap-add=SYS_PTRACE \
3940
-e OPTION=--localhost \
4041
-e TYPE=$(TYPE) evalbench:latest /evalbench/run_service.sh
4142

4243
shell:
4344
$(CONTAINER_ENGINE) run -ti --rm --net=host --name=evalbench_container \
45+
--cap-add=SYS_PTRACE \
4446
-v ~/.config/gcloud:/root/.config/gcloud \
4547
-v ~/.gitconfig:/root/.gitconfig \
4648
-v ~/.gitcookies:/root/.gitcookies \

evalbench/databases/postgres.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO {DML_USERNAME};
3535
"""
3636

37+
CONNECTOR = Connector()
3738

3839
class PGDB(DB):
3940
#####################################################
@@ -44,10 +45,9 @@ class PGDB(DB):
4445

4546
def __init__(self, db_config):
4647
super().__init__(db_config)
47-
self.connector = Connector()
4848

4949
def get_conn():
50-
conn = self.connector.connect(
50+
conn = CONNECTOR.connect(
5151
self.db_path,
5252
"pg8000",
5353
user=self.username,
@@ -74,7 +74,7 @@ def get_engine_args():
7474

7575
def close_connections(self):
7676
try:
77-
self.connector.close()
77+
self.engine.dispose()
7878
except Exception:
7979
logging.warning(
8080
f"Failed to close connections. This may result in idle unused connections."

evalbench/databases/util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import re
99
from dataclasses import dataclass, field
1010

11+
CLIENT=secretmanager_v1.SecretManagerServiceClient()
1112

1213
@dataclass
1314
class Column:
@@ -47,14 +48,13 @@ def get_db_secret(secret):
4748
"secret manager path not parsable. Could not recover password for DB."
4849
)
4950
secret_path = secret
50-
# Create a client
51-
client = secretmanager_v1.SecretManagerServiceClient()
5251
# Initialize request argument(s)
5352
request = secretmanager_v1.AccessSecretVersionRequest(
5453
name=secret_path,
5554
)
5655
# Make the request
57-
response = client.access_secret_version(request=request)
56+
response = CLIENT.access_secret_version(request=request)
57+
5858
# Return the secret
5959
return response.payload.data.decode("utf-8")
6060

evalbench/eval_service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
get_dataset_from_request,
2929
)
3030

31+
import threading
3132

3233
SESSIONMANAGER = get_SessionManager()
3334
rpc_id_var = contextvars.ContextVar("rpc_id", default="default")
@@ -132,6 +133,7 @@ async def Eval(
132133
model_config,
133134
db_configs,
134135
)
136+
logging.info(f"Finished Job ID {job_id} Thread count:{threading.active_count()}")
135137
return eval_response_pb2.EvalResponse(response=f"{job_id}")
136138

137139

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ GitPython
2626
sqlparse
2727
redis
2828
anthropic[vertex]
29-
sqlglot
29+
sqlglot
30+
pystack

0 commit comments

Comments
 (0)