|
23 | 23 | from .consts import \
|
24 | 24 | DATA_DIR, \
|
25 | 25 | LOGS_DIR, \
|
| 26 | + TMP_NODE, \ |
| 27 | + TMP_DUMP, \ |
26 | 28 | PG_CONF_FILE, \
|
27 | 29 | PG_AUTO_CONF_FILE, \
|
28 | 30 | HBA_CONF_FILE, \
|
@@ -106,7 +108,9 @@ def __enter__(self):
|
106 | 108 | def __exit__(self, type, value, traceback):
|
107 | 109 | self.free_port()
|
108 | 110 |
|
109 |
| - got_exception = value is not None |
| 111 | + # NOTE: ctrl+C does not count! |
| 112 | + got_exception = type is not None and type != KeyboardInterrupt |
| 113 | + |
110 | 114 | c1 = self.cleanup_on_good_exit and not got_exception
|
111 | 115 | c2 = self.cleanup_on_bad_exit and got_exception
|
112 | 116 |
|
@@ -152,8 +156,9 @@ def _try_shutdown(self, max_attempts):
|
152 | 156 | except ExecUtilException:
|
153 | 157 | pass # one more time
|
154 | 158 | except Exception:
|
155 |
| - # TODO: probably kill stray instance |
| 159 | + # TODO: probably should kill stray instance |
156 | 160 | eprint('cannot stop node {}'.format(self.name))
|
| 161 | + break |
157 | 162 |
|
158 | 163 | attempts += 1
|
159 | 164 |
|
@@ -195,7 +200,7 @@ def _create_recovery_conf(self, username):
|
195 | 200 |
|
196 | 201 | def _prepare_dirs(self):
|
197 | 202 | if not self.base_dir:
|
198 |
| - self.base_dir = tempfile.mkdtemp() |
| 203 | + self.base_dir = tempfile.mkdtemp(prefix=TMP_NODE) |
199 | 204 |
|
200 | 205 | if not os.path.exists(self.base_dir):
|
201 | 206 | os.makedirs(self.base_dir)
|
@@ -713,7 +718,7 @@ def dump(self, filename=None, dbname=None, username=None):
|
713 | 718 | """
|
714 | 719 |
|
715 | 720 | def tmpfile():
|
716 |
| - fd, fname = tempfile.mkstemp() |
| 721 | + fd, fname = tempfile.mkstemp(prefix=TMP_DUMP) |
717 | 722 | os.close(fd)
|
718 | 723 | return fname
|
719 | 724 |
|
|
0 commit comments