Skip to content

Commit f33f8fd

Browse files
Greg Leclercqggreg
authored andcommitted
Add timeout when waiting for coordinator
1 parent b5afd73 commit f33f8fd

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

integration_tests/fixtures.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
from prestodb.client import PrestoQuery, PrestoRequest
2929
from prestodb.constants import DEFAULT_PORT
30+
from prestodb.exceptions import TimeoutError
3031
import prestodb.logging
3132

3233

@@ -126,12 +127,19 @@ def wait_for_presto_workers(host, port, timeout=30):
126127
time.sleep(1)
127128

128129

129-
def wait_for_presto_coordinator(stream):
130+
def wait_for_presto_coordinator(stream, timeout=30):
130131
started_tag = '======== SERVER STARTED ========'
132+
t0 = time.time()
131133
for line in iter(stream.readline, b''):
134+
if line:
135+
print(line)
132136
if started_tag in line:
133137
time.sleep(5)
134138
return True
139+
if time.time() - t0 > timeout:
140+
logger.error(
141+
'coordinator took longer than {} to start'.format(timeout))
142+
raise TimeoutError
135143
return False
136144

137145

prestodb/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class DatabaseError(Exception):
4444
pass
4545

4646

47+
class TimeoutError(Exception):
48+
pass
49+
50+
4751
class PrestoQueryError(Exception):
4852
def __init__(self, error, query_id=None):
4953
self._error = error

0 commit comments

Comments
 (0)