Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4f38bd5

Browse files
author
v.shepard
committed
PBCKP-152 multihost
1 parentf131088 commit4f38bd5

File tree

4 files changed

+18
-28
lines changed

4 files changed

+18
-28
lines changed

‎testgres/cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def call_initdb(initdb_dir, log=None):
3939
call_initdb(data_dir,logfile)
4040
else:
4141
# Fetch cached initdb dir
42-
cached_data_dir=testgres_config.cached_initdb_dir
42+
cached_data_dir=testgres_config.cached_initdb_dir()
4343

4444
# Initialize cached initdb
4545

‎testgres/config.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ def cached_initdb_dir(self):
5555
defcached_initdb_dir(self,value):
5656
self._cached_initdb_dir=value
5757

58-
# NOTE: assign initial cached dir for initdb
59-
ifself.os_ops:
60-
testgres_config.cached_initdb_dir=self.os_ops.mkdtemp(prefix=TMP_CACHE)
61-
else:
62-
testgres_config.cached_initdb_dir=mkdtemp(prefix=TMP_CACHE)
63-
6458
ifvalue:
6559
cached_initdb_dirs.add(value)
6660
returntestgres_config.cached_initdb_dir
@@ -208,3 +202,7 @@ def configure_testgres(**options):
208202
"""
209203

210204
testgres_config.update(options)
205+
206+
207+
# NOTE: assign initial cached dir for initdb
208+
testgres_config.cached_initdb_dir=mkdtemp(prefix=TMP_CACHE)

‎testgres/connection.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ def __init__(self,
4242

4343
self._node=node
4444

45-
self.os_ops=OsOperations(node.host,node.hostname,node.ssh_key,node.username)
46-
self._connection=self.os_ops.db_connect(dbname=dbname,
45+
self._connection=node.os_ops.db_connect(dbname=dbname,
4746
user=username,
4847
password=password,
4948
host=node.host,

‎testgres/os_ops.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -262,32 +262,25 @@ def get_user(self):
262262
user=getpass.getuser()
263263
returnuser
264264

265-
@contextmanager
266265
defdb_connect(self,dbname,user,password=None,host='localhost',port=5432):
267266
ifself.remote:
268-
withself.ssh_connect()asssh:
269-
# Set up a local port forwarding on a random port
270-
local_port=ssh.forward_remote_port(host,port)
271-
conn=pglib.connect(
272-
host=host,
273-
port=local_port,
274-
dbname=dbname,
275-
user=user,
276-
password=password,
277-
)
278-
try:
279-
yieldconn
280-
finally:
281-
conn.close()
282-
ssh.close_forwarded_tcp(local_port)
267+
local_port=self.ssh.forward_remote_port(host,port)
268+
conn=pglib.connect(
269+
host=host,
270+
port=local_port,
271+
dbname=dbname,
272+
user=user,
273+
password=password,
274+
)
283275
else:
284-
withpglib.connect(
276+
conn=pglib.connect(
285277
host=host,
286278
port=port,
287279
dbname=dbname,
288280
user=user,
289281
password=password,
290-
)asconn:
291-
yieldconn
282+
)
283+
returnconn
284+
292285

293286

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp