def config(config, dsn):
    config.update(db={
        "cls": "aioworkers_pg.base.Connector",
        "dsn": dsn,
        "pool": {
            "connection_class": import_uri(CustomConnection),
            "record_class": import_uri(CustomRecord),
        },
    }, )
    return config
Пример #2
0
def config(config):
    config.update(base_updater=dict(
        cls=import_uri(BaseUpdater),
        autorun=False,
    ),
                  pip_updater=dict(
                      cls=import_uri(PipUpdater),
                      package=dict(name='pip'),
                      autorun=False,
                  ))
    return config
Пример #3
0
async def test_q(loop):
    conf = Config()
    conf.update({'q.cls': utils.import_uri(proxy.ProxyQueue)})

    async with Context(conf, loop=loop) as ctx:
        ctx.q.set_queue(Queue())
        await ctx.q.put(1)
        assert 1 == await ctx.q.get()
Пример #4
0
def config(config, dsn):
    config.update(
        db={
            "cls": "aioworkers_pg.base.Connector",
            "dsn": dsn,
            "pool": {
                "setup": import_uri(custom_setup),
            },
        },
    )
    return config
Пример #5
0
async def test_plq(loop):
    conf = Config()
    conf.update({
        'q.cls': utils.import_uri(proxy.PipeLineQueue),
        'q.format': 'newline:str',
    })

    async with Context(conf, loop=loop) as ctx:
        fin = io.BytesIO(b'123\n')
        fout = io.BytesIO()
        ctx.q.set_reader(fin)
        ctx.q.set_writer(fout)
        assert '123' == await ctx.q.get()
        await ctx.q.put('1')
        assert b'1\n' == fout.getvalue()