From 395cc4ac2d526e4107f80dbf1466fbc9d0cba22f Mon Sep 17 00:00:00 2001 From: Alex Chi Z Date: Tue, 17 Dec 2024 23:56:28 -0500 Subject: [PATCH] fix lambda capture Signed-off-by: Alex Chi Z --- test_runner/regress/test_pageserver_layer_rolling.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test_runner/regress/test_pageserver_layer_rolling.py b/test_runner/regress/test_pageserver_layer_rolling.py index 522a9c9fb2ae7..9ed2b2286eae5 100644 --- a/test_runner/regress/test_pageserver_layer_rolling.py +++ b/test_runner/regress/test_pageserver_layer_rolling.py @@ -42,7 +42,7 @@ async def run_worker_for_tenant( loop = asyncio.get_running_loop() sql = await loop.run_in_executor( - None, lambda: ep.safe_psql("SELECT pg_current_wal_flush_lsn()") + None, lambda ep=ep: ep.safe_psql("SELECT pg_current_wal_flush_lsn()") ) last_flush_lsn = Lsn(sql[0][0]) return last_flush_lsn @@ -50,7 +50,10 @@ async def run_worker_for_tenant( async def run_worker(env: NeonEnv, tenant_conf, entries: int) -> tuple[TenantId, TimelineId, Lsn]: loop = asyncio.get_running_loop() - tenant, timeline = await loop.run_in_executor(None, lambda: env.create_tenant(conf=tenant_conf)) + # capture tenant_conf by specifying `tenant_conf=tenant_conf`, otherwise it will be evaluated to some random value + tenant, timeline = await loop.run_in_executor( + None, lambda tenant_conf=tenant_conf, env=env: env.create_tenant(conf=tenant_conf) + ) last_flush_lsn = await run_worker_for_tenant(env, entries, tenant) return tenant, timeline, last_flush_lsn