How to use the arq.create_pool function in arq

To help you get started, we’ve selected a few arq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github samuelcolvin / arq / docs / examples / main_demo.py View on Github external
async def main():
    redis = await create_pool(RedisSettings())
    for url in ('https://facebook.com', 'https://microsoft.com', 'https://github.com'):
        await redis.enqueue_job('download_content', url)
github samuelcolvin / arq / docs / examples / retry.py View on Github external
async def main():
    redis = await create_pool(RedisSettings())
    await redis.enqueue_job('download_content', 'https://httpbin.org/status/503')
github samuelcolvin / arq / docs / examples / job_results.py View on Github external
async def main():
    redis = await create_pool(RedisSettings())

    job = await redis.enqueue_job('the_task')

    # get the job's id
    print(job.job_id)
    """
    >  68362958a244465b9be909db4b7b5ab4 (or whatever)
    """

    # get information about the job, will include results if the job has finished, but
    # doesn't await the job's result
    debug(await job.info())
    """
    >   docs/examples/job_results.py:23 main
    JobDef(
        function='the_task',
github samuelcolvin / arq / docs / examples / deferred.py View on Github external
async def main():
    redis = await create_pool(RedisSettings())

    # deferred by 10 seconds
    await redis.enqueue_job('the_task', _defer_by=10)

    # deferred by 1 minute
    await redis.enqueue_job('the_task', _defer_by=timedelta(minutes=1))

    # deferred until jan 28th 2032, you'll be waiting a long time for this...
    await redis.enqueue_job('the_task', _defer_until=datetime(2032, 1, 28))
github samuelcolvin / aiohttp-toolbox / atoolbox / db / redis.py View on Github external
async def async_flush_redis(settings: BaseSettings):
    from arq import create_pool

    redis = await create_pool(settings.redis_settings)
    await redis.flushdb()
    redis.close()
    await redis.wait_closed()
github samuelcolvin / aiohttp-toolbox / atoolbox / create_app.py View on Github external
try:
            from .db import prepare_database
            from buildpg import asyncpg
        except ImportError:
            warnings.warn('buildpg and asyncpg need to be installed to use postgres', RuntimeWarning)
        else:
            await prepare_database(settings, False)
            app['pg'] = await asyncpg.create_pool_b(dsn=settings.pg_dsn, min_size=2)

    if 'redis' not in app and getattr(settings, 'redis_settings', None):
        try:
            from arq import create_pool
        except ImportError:
            warnings.warn('arq and aioredis need to be installed to use redis', RuntimeWarning)
        else:
            app['redis'] = await create_pool(settings.redis_settings)

    if getattr(settings, 'create_http_client', False):
        timeout = getattr(settings, 'http_client_timeout', 30)
        app['http_client'] = ClientSession(timeout=ClientTimeout(total=timeout))