Skip to content

Commit

Permalink
Add timeout to server invoker
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Dec 11, 2015
1 parent d85fb68 commit 0ffabb9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/testing/mysqld.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def start(self):

logger = open(os.path.join(self.base_dir, 'tmp', 'mysqld.log'), 'wt')
pid = os.fork()
exec_at = datetime.now()
if pid == 0:
os.dup2(logger.fileno(), sys.__stdout__.fileno())
os.dup2(logger.fileno(), sys.__stderr__.fileno())
Expand All @@ -197,6 +198,9 @@ def start(self):
if os.waitpid(pid, os.WNOHANG)[0] != 0:
raise RuntimeError("*** failed to launch mysqld ***\n" + self.read_log())

if (datetime.now() - exec_at).seconds > 10.0:
raise RuntimeError("*** failed to launch mysqld (timeout) ***\n" + self.read_log())

sleep(0.1)

self.pid = pid
Expand Down

0 comments on commit 0ffabb9

Please sign in to comment.