Skip to content

Commit

Permalink
Fix connection and retry options on AsyncIOPool (#237)
Browse files Browse the repository at this point in the history
Fixes #185
  • Loading branch information
tailhook authored Sep 27, 2021
1 parent c3f320d commit 44e279f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
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

0 comments on commit 44e279f

Please sign in to comment.