Skip to content

Commit

Permalink
Add extra error logging to seek_wait() method
Browse files Browse the repository at this point in the history
  • Loading branch information
ylobankov committed Jun 6, 2022
1 parent b09dd5d commit 353d8c4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/tarantool_server.py
Expand Up @@ -464,14 +464,20 @@ def seek_wait(self, msg, proc=None, name=None, deadline=None):
break
gevent.sleep(0.001)
else:
color_stdout(
"Logfile {} does not exist".format(self.path), schema='error'
)
return False

with open(self.path, 'r') as f:
f.seek(self.log_begin, os.SEEK_SET)
cur_pos = self.log_begin
while not deadline or time.time() < deadline:
if not (proc is None):
# proc.poll() returns None if the process is working. When
# the process completed, it returns the process exit code.
if not (proc.poll() is None):
# Raise an error since the process completed.
raise TarantoolStartError(name)
log_str = f.readline()
if not log_str:
Expand All @@ -481,6 +487,12 @@ def seek_wait(self, msg, proc=None, name=None, deadline=None):
if re.findall(msg, log_str):
return True
cur_pos = f.tell()

color_stdout(
"Failed to find '{}' pattern in {} logfile".format(msg, self.path),
schema='error',
)

return False


Expand Down

0 comments on commit 353d8c4

Please sign in to comment.