Ejemplo n.º 1
0
if __name__ == '__main__':

    files = [os.path.join('/etc', f) for f in os.listdir('/etc')]

    runner = JobRunner(endpoint)
    runner.start()

    try:
        # wait to have at least 1 worker
        print 'Waiting for some workers to register -- run square_worker.py'
        while len(runner.workers) == 0:
            sys.stdout.write('.')
            sys.stdout.flush()
            time.sleep(1.)

        print
        while True:
            filecontent = runner.execute('1', random.choice(files))
            print 'File begins with %s' % filecontent[:100]


    except KeyboardInterrupt:
        runner.stop()
        print 'bye'
    except Exception, e:
        print str(e)
        print 'Something went wrong (are we still running workers?)'
        runner.stop()
        print 'bye'
Ejemplo n.º 2
0
endpoint = "ipc:///tmp/master-routing.ipc"

if __name__ == '__main__':

    runner = JobRunner(endpoint)
    runner.start()

    try:
        # wait to have at least 1 worker
        print 'Waiting for some workers to register -- run square_worker.py'
        while len(runner.workers) < 1:
            sys.stdout.write('.')
            sys.stdout.flush()
            time.sleep(1.)

        job = 0
        while True:
            print runner.execute('1', str(random.randrange(1000)))
            job += 1
            print job

        runner.stop()
    except KeyboardInterrupt:
        runner.stop()
        print 'bye'
    except Exception, e:
        print str(e)
        print 'Something went wrong (are we still running workers?)'
        runner.stop()
        print 'bye'
Ejemplo n.º 3
0
endpoint = "ipc://master-routing.ipc"

if __name__ == '__main__':

    files = [os.path.join('/etc', f) for f in os.listdir('/etc')]

    runner = JobRunner(endpoint)
    runner.start()

    try:
        # wait to have at least 1 worker
        print 'Waiting for some workers to register -- run square_worker.py'
        while len(runner.workers) == 0:
            sys.stdout.write('.')
            sys.stdout.flush()
            time.sleep(1.)

        print
        while True:
            filecontent = runner.execute('1', random.choice(files))
            print 'File begins with %s' % filecontent[:100]

    except KeyboardInterrupt:
        runner.stop()
        print 'bye'
    except Exception, e:
        print str(e)
        print 'Something went wrong (are we still running workers?)'
        runner.stop()
        print 'bye'
Ejemplo n.º 4
0
    runner = JobRunner(endpoint)
    runner.start()

    try:
        # wait to have at least 2 worker
        print 'Waiting for 2+ workers to register -- run square_worker.py'
        while len(runner.workers) < 2:
            sys.stdout.write('.')
            sys.stdout.flush()
            time.sleep(1.)

        num = str(random.randrange(1000))
        start = time.time()
        for i in range(_NUM):
            runner.execute(Job(num))
            sys.stdout.write('.')
            sys.stdout.flush()

        end = time.time() - start
        print('It took %.2f seconds to run %d jobs' % (end, _NUM))
        runner.stop()
    except KeyboardInterrupt:
        runner.stop()
        print 'bye'
    except Exception, e:
        print str(e)
        print 'Something went wrong (are we still running workers?)'
        runner.stop()
        print 'bye'
Ejemplo n.º 5
0

if __name__ == '__main__':

    runner = JobRunner(endpoint)
    runner.start()

    try:
        # wait to have at least 1 worker
        print 'Waiting for some workers to register -- run square_worker.py'
        while len(runner.workers) < 1:
            sys.stdout.write('.')
            sys.stdout.flush()
            time.sleep(1.)

        job = 0
        while True:
            print runner.execute('1', str(random.randrange(1000)))
            job += 1
            print job

        runner.stop()
    except KeyboardInterrupt:
        runner.stop()
        print 'bye'
    except Exception, e:
        print str(e)
        print 'Something went wrong (are we still running workers?)'
        runner.stop()
        print 'bye'