Exemple #1
0
def run_action(concurrency, rascal, options):
    ui = TTY(concurrency.createLock())
    ui.configure()
    ui.enableDebugCategories(options.get('debug'))
    ui.setCurrentWorkerNameFunction(lambda *args: None)
    ui.setInfoLevel(3)
    action = SyncAccounts()
    action.init(ui, concurrency, rascal, options)
    action.run()
    return action.getExitCode()
Exemple #2
0
    def setupUI(self):
        ui = TTY(self.concurrency.createLock())
        ui.configure()

        # Let ui prefix log lines with the worker name.
        ui.setCurrentWorkerNameFunction(self.concurrency.getCurrentWorkerNameFunction())
        # Apply CLI options.
        ui.enableDebugCategories(self.parser.get('debug'))
        ui.setInfoLevel(self.parser.get('info'))

        self.ui = ui
        set_module('ui', ui) # Export ui module.
Exemple #3
0
import time


import imapfw

from imapfw.concurrency.concurrency import Concurrency
from imapfw.managers.manager import Manager
from imapfw.ui.tty import TTY
from imapfw.managers.trigger import Trigger


c = Concurrency('multiprocessing')
q = c.createQueue()
q.get_nowait()

ui = TTY(c.createLock())


def output(args):
    print(args)
    sys.stdout.flush()


def runner(emitter):
    output('runner started')

    output('initA')
    emitter.initA()

    output('initB')
    emitter.initB()
Exemple #4
0
        self.arc = EngineArchitect('Engine')

    def test_00_start_stop(self):
        self.arc.init()
        self.arc.start(self.runner, ())
        self.arc.stop()

    def test_01_start_kill(self):
        self.arc.init()
        self.arc.start(self.runner, ())
        self.arc.kill()

    def test_02_getEmitter(self):
        self.arc.init()
        emitter = self.arc.getLeftEmitter()
        self.assertIsInstance(emitter, Emitter)
        emitter = self.arc.getRightEmitter()
        self.assertIsInstance(emitter, Emitter)


if __name__ == '__main__':
    from imapfw.concurrency import Concurrency
    from imapfw.ui.tty import TTY

    runtime.set_module('concurrency', Concurrency('multiprocessing'))
    ui = TTY(runtime.concurrency.createLock())
    ui.configure()
    # ui.enableDebugCategories(['architects'])
    runtime.set_module('ui', ui)
    unittest.main(verbosity=2)