diff options
author | Mark Roberts <wizzat@gmail.com> | 2014-04-25 10:55:04 -0700 |
---|---|---|
committer | Mark Roberts <wizzat@gmail.com> | 2014-04-25 10:55:04 -0700 |
commit | 57913f9f914a959f52bc9040a172f8c9ff77e491 (patch) | |
tree | fe5cc6c14283a4c9d9175a748ef97f7d55df6fd7 /test/service.py | |
parent | 0e50f33ec678f6d656d488ce8a4537f95bba003e (diff) | |
download | kafka-python-57913f9f914a959f52bc9040a172f8c9ff77e491.tar.gz |
Various fixes
Bump version number to 0.9.1
Update readme to show supported Kafka/Python versions
Validate arguments in consumer.py, add initial consumer unit test
Make service kill() child processes when startup fails
Add tests for util.py, fix Python 2.6 specific bug.
Diffstat (limited to 'test/service.py')
-rw-r--r-- | test/service.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/test/service.py b/test/service.py index 1b95cbc..78a5f24 100644 --- a/test/service.py +++ b/test/service.py @@ -66,7 +66,7 @@ class SpawnedService(threading.Thread): stderr_handle.close() def run_with_handles(self, stdout_handle, stderr_handle): - child = subprocess.Popen( + self.child = subprocess.Popen( self.args, bufsize=1, stdout=subprocess.PIPE, @@ -74,10 +74,10 @@ class SpawnedService(threading.Thread): alive = True while True: - (rds, wds, xds) = select.select([child.stdout, child.stderr], [], [], 1) + (rds, wds, xds) = select.select([self.child.stdout, self.child.stderr], [], [], 1) - if child.stdout in rds: - line = child.stdout.readline() + if self.child.stdout in rds: + line = self.child.stdout.readline() if stdout_handle: stdout_handle.write(line) stdout_handle.flush() @@ -87,8 +87,8 @@ class SpawnedService(threading.Thread): sys.stdout.write(line) sys.stdout.flush() - if child.stderr in rds: - line = child.stderr.readline() + if self.child.stderr in rds: + line = self.child.stderr.readline() if stderr_handle: stderr_handle.write(line) stderr_handle.flush() @@ -99,10 +99,10 @@ class SpawnedService(threading.Thread): sys.stderr.flush() if self.should_die.is_set(): - child.terminate() + self.child.terminate() alive = False - if child.poll() is not None: + if self.child.poll() is not None: if not alive: break else: @@ -113,6 +113,10 @@ class SpawnedService(threading.Thread): while True: t2 = time.time() if t2 - t1 >= timeout: + try: + self.child.kill() + except: + logging.exception("Received exception when killing child process") raise RuntimeError("Waiting for %r timed out" % pattern) if re.search(pattern, self.captured_stdout, re.IGNORECASE) is not None: |