Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 584
[18.0][IMP] queue_job: Default subchannel capacity and sequential.#767
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
Open
amh-mw
wants to merge
1
commit into
OCA:18.0Choose a base branch
from
amh-mw:18.0-default_subchannel_capacity
base:18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+78
−17
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -404,7 +404,16 @@ class Channel: | ||
| without risking to overflow the system. | ||
| """ | ||
| def __init__(self, name, parent, capacity=None, sequential=False, throttle=0): | ||
| def __init__( | ||
| self, | ||
| name, | ||
| parent, | ||
| capacity=None, | ||
| sequential=False, | ||
| throttle=0, | ||
| capacity_default=None, | ||
| sequential_default=False, | ||
| ): | ||
| self.name = name | ||
| self.parent = parent | ||
| if self.parent: | ||
| @@ -414,9 +423,13 @@ def __init__(self, name, parent, capacity=None, sequential=False, throttle=0): | ||
| self._running = set() | ||
| self._failed = set() | ||
| self._pause_until = 0 # utc seconds since the epoch | ||
| self.capacity = capacity | ||
| self.sequential = sequential or (parent and parent.sequential_default) | ||
| self.sequential_default = sequential_default | ||
| self.capacity = ( | ||
| capacity if (capacity is not None) else (parent and parent.capacity_default) | ||
| ) | ||
| self.capacity_default = capacity_default | ||
| self.throttle = throttle # seconds | ||
| self.sequential = sequential | ||
| @property | ||
| def sequential(self): | ||
| @@ -432,12 +445,16 @@ def configure(self, config): | ||
| Supported keys are: | ||
| * capacity | ||
| * capacity_default (default for sub channels) | ||
| * sequential | ||
| * sequential_default (default for sub channels) | ||
| * throttle | ||
| """ | ||
| assert self.fullname.endswith(config["name"]) | ||
| self.capacity = config.get("capacity", None) | ||
| self.capacity_default = config.get("capacity_default", None) | ||
| self.sequential = bool(config.get("sequential", False)) | ||
| self.sequential_default = config.get("sequential_default", False) | ||
| self.throttle = int(config.get("throttle", 0)) | ||
| if self.sequential and self.capacity != 1: | ||
| raise ValueError("A sequential channel must have a capacity of 1") | ||
| @@ -866,22 +883,23 @@ def parse_simple_config(cls, config_string): | ||
| continue | ||
| config = {} | ||
| config_items = split_strip(channel_config_string, ":") | ||
| name = config_items[0] | ||
| if not name: | ||
| if not (name := config_items.pop(0)): | ||
| raise ValueError( | ||
| f"Invalid channel config {config_string}: missing channel name" | ||
| ) | ||
| config["name"] = name | ||
| if len(config_items) > 1: | ||
| capacity = config_items[1] | ||
| if len(config_items) > 0: | ||
| try: | ||
| config["capacity"] = int(capacity) | ||
| config["capacity"] = int(config_items[0]) | ||
| config_items.pop(0) | ||
| except Exception as ex: | ||
| raise ValueError( | ||
| f"Invalid channel config {config_string}: " | ||
| f"invalid capacity {capacity}" | ||
| ) from ex | ||
| for config_item in config_items[2:]: | ||
| if name == "root": | ||
| raise ValueError( | ||
| f"Invalid channel config {config_string}: " | ||
| f"invalid capacity {config_items[0]}" | ||
| ) from ex | ||
| for config_item in config_items: | ||
| kv = split_strip(config_item, "=") | ||
| if len(kv) == 1: | ||
| k, v = kv[0], True | ||
| @@ -897,7 +915,16 @@ def parse_simple_config(cls, config_string): | ||
| f"Invalid channel config {config_string}: " | ||
| f"duplicate key {k}" | ||
| ) | ||
| config[k] = v | ||
| if k == "capacity_default": | ||
| try: | ||
| config[k] = int(v) | ||
| except Exception as ex: | ||
| raise ValueError( | ||
| f"Invalid channel config {config_string}: " | ||
| f"invalid capacity_default {v}" | ||
| ) from ex | ||
amh-mw marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| else: | ||
| config[k] = v | ||
| else: | ||
| config["capacity"] = 1 | ||
| res.append(config) | ||
| @@ -910,6 +937,17 @@ def simple_configure(self, config_string): | ||
| >>> c = cm.get_channel_by_name('root') | ||
| >>> c.capacity | ||
| 1 | ||
| >>> cm.simple_configure('root:bogus') | ||
| Traceback (most recent call last): | ||
| ... | ||
| ValueError: Invalid channel config root:bogus: invalid capacity bogus | ||
| >>> cm.simple_configure('root:4,:2') | ||
| Traceback (most recent call last): | ||
| ... | ||
| ValueError: Invalid channel config root:4,:2: missing channel name | ||
| >>> cm.simple_configure('root:4,autosub.sub:2,seq:1:sequential') | ||
| >>> cm.get_channel_by_name('root').capacity | ||
| 4 | ||
| @@ -926,7 +964,28 @@ def simple_configure(self, config_string): | ||
| 1 | ||
| >>> cm.get_channel_by_name('seq').sequential | ||
| True | ||
| """ | ||
| >>> cm.simple_configure('root:4:capacity_default=bogus') | ||
| Traceback (most recent call last): | ||
| ... | ||
| ValueError: Invalid channel config root:4:capacity_default=bogus: invalid capacity_default bogus | ||
| >>> cm.simple_configure('root:4,sub:3:capacity_default=2') | ||
| >>> cm.get_channel_by_name('root.sub').capacity | ||
| 3 | ||
| >>> cm.get_channel_by_name('root.sub.auto', autocreate=True).capacity | ||
| 2 | ||
| >>> cm.simple_configure('root:4,seq:2:sequential') | ||
| Traceback (most recent call last): | ||
| ... | ||
| ValueError: A sequential channel must have a capacity of 1 | ||
| >>> cm.simple_configure('root:4,seq:sequential_default') | ||
| >>> cm.get_channel_by_name('root.seq.auto', autocreate=True).sequential | ||
| True | ||
| """ # noqa: E501 | ||
| for config in ChannelManager.parse_simple_config(config_string): | ||
| self.get_channel_from_config(config) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.