def __init__(self, orig, pid=None): StringIO.__init__(self) self.orig = orig self._queue = Queue() if pid is None: self.pid = os.getpid() else: self.pid = pid
def _cleanup(*args, **kwargs): _queue = Queue() kwargs['queue'] = _queue try: return func(*args, **kwargs) finally: job_id = os.environ.get('MARTEAU_JOBID') if job_id is not None: _queue.delete_pids(job_id)
class RedisIO(StringIO): def __init__(self, orig): StringIO.__init__(self) self.orig = orig self._queue = Queue() def write(self, msg): self.orig.write(msg) job_id = self._queue.pid_to_jobid(os.getpid()) if job_id is not None: self._queue.append_console(job_id, msg)
class RedisIO(StringIO): def __init__(self, orig, pid=None): StringIO.__init__(self) self.orig = orig self._queue = Queue() if pid is None: self.pid = os.getpid() else: self.pid = pid def write(self, msg): self.orig.write(msg) job_id = self._queue.pid_to_jobid(self.pid) if job_id is not None: self._queue.append_console(job_id, msg)
def __init__(self, orig): StringIO.__init__(self) self.orig = orig self._queue = Queue()
import os import tempfile from fabric.operations import put from fabric.decorators import parallel, hosts from marteau.queue import Queue nodes = [node.name for node in Queue().get_nodes()] @parallel # can be used if the key agent is loaded @hosts(*nodes) def deploy_key(): """Deploy the auth key to all nodes""" fd, path = tempfile.mkstemp() os.close(fd) with open(path, 'w') as f: try: f.write(os.environ['AUTH_KEY']) except KeyError: msg = 'Make sure you define an AUTH_KEY in the env.' raise KeyError(msg) try: put(local_path=path, remote_path='/home/marteau/loadtest.auth', mode=0770) finally: os.remove(path)