Skip to content

[18.0][IMP] queue_job: Default subchannel capacity and sequential.#767

Open
amh-mw wants to merge 1 commit into
OCA:18.0from
amh-mw:18.0-default_subchannel_capacity
Open

[18.0][IMP] queue_job: Default subchannel capacity and sequential.#767
amh-mw wants to merge 1 commit into
OCA:18.0from
amh-mw:18.0-default_subchannel_capacity

Conversation

@amh-mw

@amh-mw amh-mw commented May 7, 2025

Copy link
Copy Markdown
Member

This adds capacity_default and sequential_default options that set capacity and sequential for autocreated subchannels. It also allows non-root channel configurations to omit capacity.

@OCA-git-bot

Copy link
Copy Markdown
Contributor

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

Comment thread queue_job/tests/test_runner_channels.py Outdated
@amh-mw amh-mw force-pushed the 18.0-default_subchannel_capacity branch from 3b234e1 to 317854f Compare June 3, 2025 12:03
Comment thread queue_job/jobrunner/channels.py Outdated
@amh-mw amh-mw force-pushed the 18.0-default_subchannel_capacity branch from 317854f to 654f17e Compare June 3, 2025 17:46

@sbidoul sbidoul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thanks!

Could expand the docstring of parse_simple_config a bit (around line 823).

The only question I'd have is if we can come up for a better name to convey "default subchannel capacity". I don't have any better idea for now.

@amh-mw

amh-mw commented Jun 6, 2025

Copy link
Copy Markdown
Member Author

The only question I'd have is if we can come up for a better name to convey "default subchannel capacity". I don't have any better idea for now.

Given existing documentation:

Channels: give a capacity for the root channel and its sub-channels and segregate jobs in them. Allow for instance to restrict heavy jobs to be executed one at a time while little ones are executed 4 at a times.

Noodling around in tests:

cm = channels.ChannelManager()
cm.simple_configure("root:2,child")
root = cm.get_channel_by_name("root")
self.assertEqual(root.capacity, 2)
child = cm.get_channel_by_name("child")
self.assertEqual(child.capacity, 1)
auto = cm.get_channel_by_name("auto", autocreate=True)
self.assertEqual(auto.capacity, None)

The difference in capacity between an autocreated subchannel and a configured subchannel was the impetus for the creation of this pull request. Maybe rename subcapacity to autocapacity? Testing shows that the new setting does not change the capacity for configured subchannels.

cm = channels.ChannelManager()
cm.simple_configure("root:4:subcapacity=2,child")
root = cm.get_channel_by_name("root")
self.assertEqual(root.capacity, 4)
child = cm.get_channel_by_name("child")
self.assertEqual(child.capacity, 1)

@github-actions

github-actions Bot commented Oct 5, 2025

Copy link
Copy Markdown

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions Bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Oct 5, 2025
@VecSec

VecSec commented Nov 6, 2025

Copy link
Copy Markdown

Hi, awesome feature great job. May you merge? @amh-mw

@sbidoul sbidoul removed the stale PR/Issue without recent activity, it'll be soon closed automatically. label Nov 6, 2025

@sbidoul sbidoul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't have a better idea for a config name. default_subchannel_capacity might be better but it's a bit long?

Can you add doctests in the ChannelManager class? You can look at how it is done for the throttle config to get inspiration.

Comment thread queue_job/jobrunner/channels.py
@sbidoul sbidoul added this to the 18.0 milestone Jan 2, 2026
@sbidoul

sbidoul commented Jan 21, 2026

Copy link
Copy Markdown
Member

While discussing this with a colleague we found a use case where it would be interesting to configure subchannels with default capacity 1 + sequential, so maybe we should generalize this PR.

@amh-mw

amh-mw commented Apr 30, 2026

Copy link
Copy Markdown
Member Author

While discussing this with a colleague we found a use case where it would be interesting to configure subchannels with default capacity 1 + sequential, so maybe we should generalize this PR.

@sbidoul If you would be so kind as to create a new issue for that use case, I'd be happy to take a look, but I am loathe to add features to an approved pull request that is about to turn one year old. 🎉

@sbidoul

sbidoul commented Apr 30, 2026

Copy link
Copy Markdown
Member

Hi @amh-mw, I've looked at this again and I think my last comments still stand.

  • I would like the test to be added as doctests to ChannelManager.simple_configure, like other similar tests, instead of new test classes. I'm aware the doctests currently don't run in CI but they can be run manually, and it's important to keep similar things together.
  • Can you please move the parsing of the subcapacity config value to the configure method, like it is done for throttle, to keep the same code style. Except for capacity which is special for the config parser, the parse_simple_config method does not have specific knowledge of the config keys.
  • Since we will likely want to extend to other default config keys for subchannels, I propose to rename it to def_sub_capacity. So we can later add def_sub_sequential, etc.

@amh-mw amh-mw force-pushed the 18.0-default_subchannel_capacity branch from 654f17e to 4805f13 Compare July 14, 2026 12:04
@amh-mw amh-mw force-pushed the 18.0-default_subchannel_capacity branch 4 times, most recently from 59146fd to 1edfdf3 Compare July 14, 2026 14:27
@amh-mw amh-mw changed the title [18.0][IMP] queue_job: Configure default subchannel capacity. [18.0][IMP] queue_job: Default subchannel capacity and sequential. Jul 14, 2026
@amh-mw amh-mw requested a review from sbidoul July 14, 2026 14:36
@amh-mw

amh-mw commented Jul 14, 2026

Copy link
Copy Markdown
Member Author

While discussing this with a colleague we found a use case where it would be interesting to configure subchannels with default capacity 1 + sequential, so maybe we should generalize this PR.

I went ahead and added sequential_default.

@amh-mw amh-mw force-pushed the 18.0-default_subchannel_capacity branch from 1edfdf3 to f23b8d5 Compare July 14, 2026 14:46
@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Comment thread queue_job/jobrunner/channels.py Outdated
Comment thread queue_job/jobrunner/channels.py
Comment thread queue_job/jobrunner/channels.py Outdated
Comment thread queue_job/jobrunner/channels.py Outdated
@amh-mw amh-mw force-pushed the 18.0-default_subchannel_capacity branch from f23b8d5 to c199309 Compare July 15, 2026 13:42
Comment thread queue_job/jobrunner/channels.py Outdated
Comment thread queue_job/jobrunner/channels.py Outdated
Comment thread queue_job/jobrunner/channels.py Outdated
@amh-mw amh-mw force-pushed the 18.0-default_subchannel_capacity branch from c199309 to 11805f6 Compare July 15, 2026 14:27

@sbidoul sbidoul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is a useful feature.

@amh-mw

amh-mw commented Jul 15, 2026

Copy link
Copy Markdown
Member Author

Hold off for a second, test logs have

**********************************************************************
File "/mnt/extra-addons/oca/queue/queue_job/jobrunner/channels.py", line 986, in odoo.addons.queue_job.jobrunner.channels.ChannelManager.simple_configure
Failed example:
    cm.get_channel_by_name('root.seq.auto', autocreate=True).capacity
Expected:
    1
Got nothing
**********************************************************************
1 items had failures:
   1 of  23 in odoo.addons.queue_job.jobrunner.channels.ChannelManager.simple_configure
***Test Failed*** 1 failures.

but no error.

This adds `capacity_default` and `sequential_default` options
that set `capacity` and `sequential` for autocreated subchannels.
It also allows non-root channel configurations to omit capacity.
@amh-mw amh-mw force-pushed the 18.0-default_subchannel_capacity branch from 11805f6 to 0a40c6e Compare July 15, 2026 14:53
@amh-mw

amh-mw commented Jul 15, 2026

Copy link
Copy Markdown
Member Author

I removed the defaulting of capacity=1 when sequential=True and gave doctest its teeth back.

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.

7 participants