Esempio n. 1
0
def main():
    parser = argparse.ArgumentParser(
            description='Run a single task processor',
            formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument('--host', '-H', dest='host',
            type=str, help='connect to host')
    parser.add_argument('--port', '-p', dest='port',
            type=int, help='port number')
    parser.add_argument('--unix_path', '-u', dest='unix_path',
            type=str, help='connect to Unix domain socket')
    parser.add_argument('--loop', '-l', dest='loop', default=0,
            type=int, help='0=default 1=asyncio 2=uvloop 3=proactor 4=quamash')
    args = parser.parse_args()

    if args.loop == LoopType.default:
        loop = util.get_loop()
    elif args.loop == LoopType.asyncio:
        loop = asyncio.get_event_loop()
    elif args.loop == LoopType.uvloop:
        import uvloop
        loop = uvloop.Loop()
    elif args.loop == LoopType.proactor:
        loop = asyncio.ProactorEventLoop()
    elif args.loop == LoopType.quamash:
        import quamash
        import PyQt5.Qt as qt
        _qapp = qt.QApplication([])
        loop = quamash.QEventLoop()
    asyncio.set_event_loop(loop)
    processor = Processor(args.host, args.port, args.unix_path, loop=loop)
    loop.run_forever()
Esempio n. 2
0
def main():
    parser = argparse.ArgumentParser(
        description='Run a single task processor',
        formatter_class=argparse.RawTextHelpFormatter)
    parser.add_argument('--host',
                        '-H',
                        dest='host',
                        type=str,
                        help='connect to host')
    parser.add_argument('--port',
                        '-p',
                        dest='port',
                        type=int,
                        help='port number')
    parser.add_argument('--unix_path',
                        '-u',
                        dest='unix_path',
                        type=str,
                        help='connect to Unix domain socket')
    parser.add_argument(
        '--loop',
        '-l',
        dest='loop',
        default=0,
        type=int,
        help='0=default 1=asyncio 2=uvloop 3=proactor 4=quamash')
    parser.add_argument('--func_pickle',
                        '-f',
                        dest='func_pickle',
                        default=1,
                        type=int,
                        help='0=pickle 1=cloudpickle 2=dill')
    parser.add_argument('--data_pickle',
                        '-d',
                        dest='data_pickle',
                        default=0,
                        type=int,
                        help='0=pickle 1=cloudpickle 2=dill')
    args = parser.parse_args()
    if not args.port and not args.unix_path:
        print('distex installed OK')
        return

    if args.loop == LoopType.default:
        loop = util.get_loop()
    elif args.loop == LoopType.asyncio:
        loop = asyncio.get_event_loop()
    elif args.loop == LoopType.uvloop:
        import uvloop
        loop = uvloop.Loop()
    elif args.loop == LoopType.proactor:
        loop = asyncio.ProactorEventLoop()
    elif args.loop == LoopType.quamash:
        import quamash
        import PyQt5.Qt as qt
        qapp = qt.QApplication([])  # noqa
        loop = quamash.QEventLoop()
    asyncio.set_event_loop(loop)
    processor = Processor(  # noqa
        args.host, args.port, args.unix_path, args.func_pickle,
        args.data_pickle)
    loop.run_forever()
Esempio n. 3
0
import sys
import time
import cProfile
import pstats
import asyncio
import traceback

from distex import Pool, util

loop = util.get_loop()
asyncio.set_event_loop(loop)
# util.logToConsole(logging.DEBUG)

# import quamash
# import PyQt5.Qt as qt
# qApp = qt.QApplication([])
# loop = quamash.QEventLoop()
# asyncio.set_event_loop(loop)

# loop.set_debug(True)

loop = asyncio.get_event_loop()
REPS = 100000


def f(x):
    import math
    for _ in range(10000):
        x += math.sin(x)
    return x