Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix connection and retry options on AsyncIOPool #237

Merged
merged 3 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions edgedb/asyncio_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,12 @@ def raw_transaction(self) -> _transaction.AsyncIOTransaction:
def retrying_transaction(self) -> _retry.AsyncIORetry:
return _retry.AsyncIORetry(self)

def _shallow_clone(self):
new_pool = self.__class__.__new__(self.__class__)
new_pool._options = self._options
new_pool._impl = self._impl
return new_pool


class PoolAcquireContext:

Expand Down
2 changes: 1 addition & 1 deletion edgedb/pgproto
13 changes: 13 additions & 0 deletions tests/test_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,19 @@ async def test_pool_retry(self):

await pool.aclose()

async def test_pool_options(self):
pool = await self.create_pool(min_size=1, max_size=1)

pool.with_transaction_options(edgedb.TransactionOptions(readonly=True))
pool.with_retry_options(
edgedb.RetryOptions(attempts=1, backoff=edgedb.default_backoff)
)
async for tx in pool.retrying_transaction():
async with tx:
self.assertEqual(await tx.query_single("SELECT 7*8"), 56)

await pool.aclose()

def test_pool_init_run_until_complete(self):
pool_init = self.create_pool()
pool = self.loop.run_until_complete(pool_init)
Expand Down