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

[BCP] queue_job: standalone jobrunner from 14.0 to 11.0 #456

Merged
merged 3 commits into from
Sep 7, 2022

Conversation

thomaspaulb
Copy link

Backport of: #409

@OCA-git-bot
Copy link
Contributor

Hi @guewen,
some modules you are maintaining are being modified, check this out!

@thomaspaulb thomaspaulb force-pushed the 11.0-bcp-standalone_job_runner branch from d510c2b to 16853fc Compare August 30, 2022 14:25
@thomaspaulb thomaspaulb force-pushed the 11.0-bcp-standalone_job_runner branch from 16853fc to 60f7c0d Compare August 30, 2022 14:33
@thomaspaulb
Copy link
Author

I can't get this to run with env ODOO_RC=odoo.cfg python -m odoo.addons.queue_job.jobrunner like the original PR mentions, I get:

/home/nightly/odoo/.venv/bin/python: Error while finding module specification for 'odoo.addons.queue_job.jobrunner' (ModuleNotFoundError: No module named 'odoo.addons.queue_job')

It only works with: env ODOO_RC=auto/odoo.conf python -c "import odoo; odoo.tools.config.parse_config(); from odoo.addons import queue_job; runner = queue_job.jobrunner.QueueJobRunner.from_environ_or_config(); runner.run()"

@thomaspaulb thomaspaulb force-pushed the 11.0-bcp-standalone_job_runner branch from 60f7c0d to 27df86e Compare August 30, 2022 14:47
@sbidoul
Copy link
Member

sbidoul commented Aug 31, 2022

I can't get this to run with env ODOO_RC=odoo.cfg python -m odoo.addons.queue_job.jobrunner

Ah, yes. You likely have the queue repo in odoo.cfg addons_path. Therefore odoo.addons.queue_job is not known to the python import machinery until odoo.tools.config.parse_config has run, so python -m can't possibly find it.

Things you can do:

  • install this queue_job PR with pip: pip install git+https://github.com/oca/queue@refs/pull/456/head#subdirectory=setup/queue_job. That will install it in site-package, hence in sys.path.
  • add queue/setup/queue_job in PYTHONPATH (there is odoo/addons/queue_job there) -- although don't rely on that, since this setup directory will likely disappear in the future, so I just mention it as it may help explaining the mechanism.
  • or, run __main__.py as a script: python queue/queue_job/job_runner/__main__.py

@sbidoul
Copy link
Member

sbidoul commented Aug 31, 2022

There are two unrelated commits in this PR?

@thomaspaulb
Copy link
Author

@sbidoul

  • I went for just putting the long python -c command in my jobrunner service, are the methods you mention better in some way? (except for being more elegant)

  • The commits are not unrelated, they are commits that I cherry-picked from the 14.0 branch that are required for it to work

@sbidoul
Copy link
Member

sbidoul commented Aug 31, 2022

are the methods you mention better in some way? (except for being more elegant)

Running __main__.py as a script avoids some minor code duplication in your job runner service. Otherwise, they should be equivalent at runtime.

@guewen
Copy link
Member

guewen commented Sep 7, 2022

/ocabot merge minor

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 11.0-ocabot-merge-pr-456-by-guewen-bump-minor, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 5479b18 into OCA:11.0 Sep 7, 2022
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 4deefca. Thanks a lot for contributing to OCA. ❤️

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

Successfully merging this pull request may close these issues.

5 participants