Skip to content

Commit

Permalink
fix lambda capture
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Chi Z <chi@neon.tech>
  • Loading branch information
skyzh committed Dec 18, 2024
1 parent 7f06138 commit 395cc4a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test_runner/regress/test_pageserver_layer_rolling.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,18 @@ 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


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

Expand Down

0 comments on commit 395cc4a

Please sign in to comment.