Skip to content

Commit 242066f

Browse files
committed
Fixes
1 parent dcb3816 commit 242066f

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

asyncpg/_testbase/__init__.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@ def wrapper(self, *args, __meth__=meth, **kwargs):
7979
timeout = getattr(__meth__, '__timeout__', mcls.TEST_TIMEOUT)
8080
if timeout:
8181
coro = asyncio.wait_for(coro, timeout, loop=self.loop)
82-
try:
82+
try:
83+
self.loop.run_until_complete(coro)
84+
except asyncio.TimeoutError:
85+
raise self.failureException(
86+
'test timed out after {} seconds'.format(
87+
timeout)) from None
88+
else:
8389
self.loop.run_until_complete(coro)
84-
except asyncio.TimeoutError:
85-
raise self.failureException(
86-
'test timed out after {} seconds'.format(
87-
timeout)) from None
8890
ns[methname] = wrapper
8991

9092
return super().__new__(mcls, name, bases, ns)

asyncpg/cluster.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,24 @@ def start(self, wait=60, *, server_settings={}, **opts):
202202
# of postgres daemon under an Administrative account
203203
# is not permitted and there is no easy way to drop
204204
# privileges.
205+
if os.getenv('ASYNCPG_DEBUG_SERVER'):
206+
stdout = sys.stdout
207+
else:
208+
stdout = subprocess.DEVNULL
209+
205210
process = subprocess.run(
206211
[self._pg_ctl, 'start', '-D', self._data_dir,
207212
'-o', ' '.join(extra_args)],
208-
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
209-
stderr = process.stderr
213+
stdout=stdout, stderr=subprocess.STDOUT)
210214

211215
if process.returncode != 0:
216+
if process.stderr:
217+
stderr = ':\n{}'.format(process.stderr.decode())
218+
else:
219+
stderr = ''
212220
raise ClusterError(
213-
'pg_ctl start exited with status {:d}: {}'.format(
214-
process.returncode, stderr.decode()))
221+
'pg_ctl start exited with status {:d}{}'.format(
222+
process.returncode, stderr))
215223
else:
216224
if os.getenv('ASYNCPG_DEBUG_SERVER'):
217225
stdout = sys.stdout
@@ -448,6 +456,7 @@ def _test_connection(self, timeout=60):
448456
try:
449457
con = loop.run_until_complete(
450458
asyncpg.connect(database='postgres',
459+
user='postgres',
451460
timeout=5, loop=loop,
452461
**self._connection_addr))
453462
except (OSError, asyncio.TimeoutError,

asyncpg/pool.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ async def release(self, timeout):
201201
await asyncio.wait_for(
202202
self._con._protocol._wait_for_cancellation(),
203203
timeout, loop=self._pool._loop)
204-
budget -= time.monotonic() - started
204+
if budget is not None:
205+
budget -= time.monotonic() - started
205206

206207
await self._con.reset(timeout=budget)
207208
except Exception as ex:

0 commit comments

Comments
 (0)