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
[19.0] [MIG] queue_job: migrate + tests#840
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -11,7 +11,7 @@ | ||
| from psycopg2 import OperationalError, errorcodes | ||
| from werkzeug.exceptions import BadRequest, Forbidden | ||
| from odoo import SUPERUSER_ID, _, api, http | ||
| from odoo import SUPERUSER_ID, api, http | ||
| from odoo.modules.registry import Registry | ||
| from odoo.service.model import PG_CONCURRENCY_ERRORS_TO_RETRY | ||
| @@ -179,7 +179,7 @@ def create_test_job( | ||
| failure_rate=0, | ||
| ): | ||
| if not http.request.env.user.has_group("base.group_erp_manager"): | ||
| raise Forbidden(_("Access Denied")) | ||
| raise Forbidden(http.request.env._("Access Denied")) | ||
| if failure_rate is not None: | ||
| try: | ||
| @@ -280,7 +280,7 @@ def _create_graph_test_jobs( | ||
| priority=priority, | ||
| max_retries=max_retries, | ||
| channel=channel, | ||
| description="%s #%d" % (description, current_count), | ||
| description=f"{description} #{current_count}", | ||
sbidoul marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| )._test_job(failure_rate=failure_rate) | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -209,7 +209,8 @@ def load(cls, env, job_uuid): | ||
| """ | ||
| stored = cls.db_records_from_uuids(env, [job_uuid]) | ||
| if not stored: | ||
| raise NoSuchJobError(f"Job {job_uuid} does no longer exist in the storage.") | ||
| msg = f"Job {job_uuid} does no longer exist in the storage." | ||
| raise NoSuchJobError(msg) | ||
| return cls._load_from_db_record(stored) | ||
| @classmethod | ||
| @@ -505,7 +506,7 @@ def perform(self): | ||
| # traceback and message: | ||
| # http://blog.ianbicking.org/2007/09/12/re-raising-exceptions/ | ||
| new_exc = FailedJobError( | ||
| "Max. retries (%d) reached: %s" % (self.max_retries, value or type_) | ||
| f"Max. retries ({self.max_retries}) reached: {value or type_}" | ||
sbidoul marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ) | ||
| raise new_exc from err | ||
| raise | ||
| @@ -813,7 +814,7 @@ def set_failed(self, **kw): | ||
| setattr(self, k, v) | ||
| def __repr__(self): | ||
| return "<Job %s, priority:%d>" % (self.uuid, self.priority) | ||
| return f"<Job {self.uuid}, priority:{self.priority}>" | ||
sbidoul marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| def _get_retry_seconds(self, seconds=None): | ||
| retry_pattern = self.job_config.retry_pattern | ||
| @@ -828,7 +829,7 @@ def _get_retry_seconds(self, seconds=None): | ||
| break | ||
| elif not seconds: | ||
| seconds = RETRY_INTERVAL | ||
| if isinstance(seconds, (list | tuple)): | ||
| if isinstance(seconds, list | tuple): | ||
| seconds = randint(seconds[0], seconds[1]) | ||
| return seconds | ||
| @@ -856,8 +857,7 @@ def related_action(self): | ||
| funcname = record._default_related_action | ||
| if not isinstance(funcname, str): | ||
| raise ValueError( | ||
| "related_action must be the name of the " | ||
| "method on queue.job as string" | ||
| "related_action must be the name of the method on queue.job as string" | ||
| ) | ||
| action = getattr(record, funcname) | ||
| action_kwargs = self.job_config.related_action_kwargs | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -455,12 +455,9 @@ def get_subchannel_by_name(self, subchannel_name): | ||
| def __str__(self): | ||
| capacity = "∞" if self.capacity is None else str(self.capacity) | ||
| return "%s(C:%s,Q:%d,R:%d,F:%d)" % ( | ||
| self.fullname, | ||
| capacity, | ||
| len(self._queue), | ||
| len(self._running), | ||
| len(self._failed), | ||
| return ( | ||
| f"{self.fullname}(C:{capacity},Q:{len(self._queue)}," | ||
| f"R:{len(self._running)},F:{len(self._failed)})" | ||
sbidoul marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ) | ||
| def remove(self, job): | ||
| @@ -894,8 +891,7 @@ def parse_simple_config(cls, config_string): | ||
| ) | ||
| if k in config: | ||
| raise ValueError( | ||
| f"Invalid channel config {config_string}: " | ||
| f"duplicate key {k}" | ||
| f"Invalid channel config {config_string}: duplicate key {k}" | ||
| ) | ||
| config[k] = v | ||
| else: | ||
| @@ -996,7 +992,8 @@ def get_channel_by_name( | ||
| if channel_name in self._channels_by_name: | ||
| return self._channels_by_name[channel_name] | ||
| if not autocreate and not parent_fallback: | ||
| raise ChannelNotFound(f"Channel {channel_name} not found") | ||
| msg = f"Channel {channel_name} not found" | ||
| raise ChannelNotFound(msg) | ||
| parent = self._root_channel | ||
| if parent_fallback: | ||
| # Look for first direct parent w/ config. | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.