mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Fix pool_recycle implementation
- Fix environment variable name from DB_MAX_OVERFLOW to DB_POOL_RECYCLE - Add pool_recycle parameter to all engine configurations (sync and async) - Revert unrelated change to remote_sandbox_service.py
This commit is contained in:
parent
4aec890351
commit
6d81539cbd
@ -19,7 +19,7 @@ GCP_REGION = os.environ.get('GCP_REGION')
|
||||
|
||||
POOL_SIZE = int(os.environ.get('DB_POOL_SIZE', '25'))
|
||||
MAX_OVERFLOW = int(os.environ.get('DB_MAX_OVERFLOW', '10'))
|
||||
POOL_RECYCLE = int(os.environ.get('DB_MAX_OVERFLOW', '1800'))
|
||||
POOL_RECYCLE = int(os.environ.get('DB_POOL_RECYCLE', '1800'))
|
||||
|
||||
|
||||
def _get_db_engine():
|
||||
@ -50,6 +50,7 @@ def _get_db_engine():
|
||||
host_string,
|
||||
pool_size=POOL_SIZE,
|
||||
max_overflow=MAX_OVERFLOW,
|
||||
pool_recycle=POOL_RECYCLE,
|
||||
pool_pre_ping=True,
|
||||
)
|
||||
|
||||
|
||||
@ -356,7 +356,7 @@ class RemoteSandboxService(SandboxService):
|
||||
StoredRemoteSandbox.id == runtime.get('session_id')
|
||||
)
|
||||
result = await self.db_session.execute(query)
|
||||
sandbox = result.first()
|
||||
sandbox = result.scalar_one_or_none()
|
||||
if sandbox is None:
|
||||
raise ValueError('sandbox_not_found')
|
||||
return self._to_sandbox_info(sandbox, runtime)
|
||||
|
||||
@ -176,6 +176,7 @@ class DbSessionInjector(BaseModel, Injector[async_sessionmaker]):
|
||||
url,
|
||||
pool_size=self.pool_size,
|
||||
max_overflow=self.max_overflow,
|
||||
pool_recycle=self.pool_recycle,
|
||||
pool_pre_ping=True,
|
||||
)
|
||||
else:
|
||||
@ -216,6 +217,7 @@ class DbSessionInjector(BaseModel, Injector[async_sessionmaker]):
|
||||
url,
|
||||
pool_size=self.pool_size,
|
||||
max_overflow=self.max_overflow,
|
||||
pool_recycle=self.pool_recycle,
|
||||
pool_pre_ping=True,
|
||||
)
|
||||
self._engine = engine
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user