Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resubmission of job with same id causes conflict #137

Closed
adamshamsudeen opened this issue Aug 1, 2019 · 2 comments · Fixed by #138
Closed

Resubmission of job with same id causes conflict #137

adamshamsudeen opened this issue Aug 1, 2019 · 2 comments · Fixed by #138
Labels

Comments

@adamshamsudeen
Copy link

Suppose I add a job to a queue and later I add another job with the same job_id then even before the completion of job it returns JobStatus.complete.

example:

import asyncio
from aiohttp import ClientSession
from arq import create_pool
from arq.connections import RedisSettings

async def download_content(ctx, url):
    session: ClientSession = ctx['session']
    async with session.get(url) as response:
        content = await response.text()
        print(f'{url}: {content:.80}...')
    return len(content)

async def startup(ctx):
    ctx['session'] = ClientSession()

async def shutdown(ctx):
    await ctx['session'].close()


async def main():
    redis = await create_pool(RedisSettings())
    job_list = []
    for url in ('https://facebook.com', 'https://microsoft.com', 'https://github.com'):
        job = await redis.enqueue_job('download_content', url, _job_id=url)
        job_list.append(job)

    for j_ in job_list:
        print( j_.job_id)
        print(await j_.status())
# WorkerSettings defines the settings to use when creating the work,
# it's used by the arq cli
class WorkerSettings:
    functions = [download_content]
    on_startup = startup
    on_shutdown = shutdown

if __name__ == '__main__':
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

Running this twice:

(sanic) ╭─adam@adams-MacBook-Air ~/sidekik 
╰─$ python arqq_.py
https://facebook.com
JobStatus.queued
https://microsoft.com
JobStatus.queued
https://github.com
JobStatus.queued
(sanic) ╭─adam@adams-MacBook-Air ~/sidekik 
╰─$ python arqq_.py
https://facebook.com
JobStatus.complete
https://microsoft.com
JobStatus.complete
https://github.com
JobStatus.complete
@samuelcolvin
Copy link
Member

Thanks for reporting, should be fixed in #138. Please can you check that solves your problem.

@adamshamsudeen
Copy link
Author

Thank you for the quick fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants