Warning

This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

Source code for tool_shed.galaxy_install.tool_dependencies.recipe.asynchronous_reader

import logging
import threading

log = logging.getLogger(__name__)


[docs]class AsynchronousReader(threading.Thread): """ A helper class to implement asynchronous reading of a stream in a separate thread. Read lines are pushed onto a queue to be consumed in another thread. """
[docs] def __init__(self, fd, queue): threading.Thread.__init__(self) self._fd = fd self._queue = queue self.lines = []
[docs] def run(self): """Read lines and put them on the queue.""" thread_lock = threading.Lock() thread_lock.acquire() for line in iter(self._fd.readline, ''): stripped_line = line.rstrip() self.lines.append(stripped_line) self._queue.put(stripped_line) thread_lock.release()
[docs] def installation_complete(self): """Make sure there is more installation and compilation logging content expected.""" return not self.is_alive() and self._queue.empty()