From cfde98e54a44c98f324553929ff7c951ceb1ba33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 28 Oct 2023 00:16:32 +0200 Subject: [PATCH] Backed out changeset fc478f7d7004 --- sao/src/common.js | 6 ++--- sao/src/model.js | 2 +- sao/src/rpc.js | 10 -------- sao/src/sao.js | 2 +- sao/src/screen.js | 7 +++--- sao/src/view/form.js | 14 +++++------ tryton/tryton/common/common.py | 4 ---- tryton/tryton/common/selection.py | 9 +++---- tryton/tryton/gui/main.py | 8 +++---- .../gui/window/view_form/model/record.py | 6 ++--- .../gui/window/view_form/screen/screen.py | 6 ++--- .../view_form/view/form_gtk/state_widget.py | 9 +++---- trytond/CHANGELOG | 1 - trytond/doc/ref/rpc.rst | 8 +------ trytond/doc/topics/configuration.rst | 7 ------ trytond/trytond/backend/__init__.py | 4 +--- trytond/trytond/backend/database.py | 4 +--- .../trytond/backend/postgresql/__init__.py | 5 ++-- .../trytond/backend/postgresql/database.py | 17 ++++--------- trytond/trytond/backend/sqlite/__init__.py | 5 ++-- trytond/trytond/backend/sqlite/database.py | 10 ++------ trytond/trytond/config.py | 1 - trytond/trytond/ir/model.py | 4 +--- trytond/trytond/model/modelstorage.py | 15 ++++-------- trytond/trytond/protocols/dispatcher.py | 6 +---- trytond/trytond/rpc.py | 6 ++--- trytond/trytond/tests/test_transaction.py | 24 ------------------- trytond/trytond/transaction.py | 4 ++-- 28 files changed, 50 insertions(+), 154 deletions(-) diff --git a/sao/src/common.js b/sao/src/common.js index 1b3bafb36c..74d94edf96 100644 --- a/sao/src/common.js +++ b/sao/src/common.js @@ -721,11 +721,9 @@ if (!(selection instanceof Array) && !(key in this._values2selection)) { if (!jQuery.isEmptyObject(this.attributes.selection_change_with)) { - prm = this.model.execute( - selection, [value], {}, true, false); + prm = this.model.execute(selection, [value]); } else { - prm = this.model.execute( - selection, [], {}, true, false); + prm = this.model.execute(selection, []); } prm = prm.then(selection => { this._values2selection[key] = selection; diff --git a/sao/src/model.js b/sao/src/model.js index 3f2f89d3a1..0808dd52c2 100644 --- a/sao/src/model.js +++ b/sao/src/model.js @@ -1226,7 +1226,7 @@ try { result = this.model.execute( 'autocomplete_' + fieldname, [values], this.get_context(), - false, false); + false); } catch (e) { result = []; } diff --git a/sao/src/rpc.js b/sao/src/rpc.js index d5852209a7..ea5a51ae44 100644 --- a/sao/src/rpc.js +++ b/sao/src/rpc.js @@ -113,11 +113,6 @@ }; var ajax_error = function(query, status_, error) { - if (!process_exception) { - console.debug(`RPC error calling ${args}: ${status_}: ${error}.`); - dfd.reject(); - return; - } if (query.status == 401) { //Try to relog Sao.Session.renew(session).then(function() { @@ -128,11 +123,6 @@ dfd.resolve(); } }, dfd.reject); - } else if (query.status == 408) { - Sao.common.message.run( - Sao.i18n.gettext('Request times out. Try again later.'), - 'tryton-error') - .always(dfd.reject); } else if (query.status == 429) { Sao.common.message.run( Sao.i18n.gettext('Too many requests. Try again later.'), diff --git a/sao/src/sao.js b/sao/src/sao.js index d0b284c498..8b5d18d634 100644 --- a/sao/src/sao.js +++ b/sao/src/sao.js @@ -1021,7 +1021,7 @@ var Sao = { } return ir_model.execute('global_search', [text, Sao.config.limit, Sao.main_menu_screen.model_name], - Sao.main_menu_screen.context, true, false) + Sao.main_menu_screen.context) .then(s_results => { var results = []; for (const result of s_results) { diff --git a/sao/src/screen.js b/sao/src/screen.js index 5eae4f1f6c..89acb8a6c5 100644 --- a/sao/src/screen.js +++ b/sao/src/screen.js @@ -1068,8 +1068,7 @@ (ids.length == this.limit)) { count_prm = this.model.execute( 'search_count', - [domain, 0, this.count_limit], context, - true, false) + [domain, 0, this.count_limit], context) .then(count => { this.search_count = count; return this.search_count; @@ -1820,10 +1819,10 @@ values[p] = null; } selection = this.model.execute(props.selection, - [values], undefined, false, true); + [values], undefined, false); } else { selection = this.model.execute(props.selection, - [], undefined, false, true); + [], undefined, false); } return selection.sort(function(a, b) { return a[1].localeCompare(b[1]); diff --git a/sao/src/view/form.js b/sao/src/view/form.js index 64642433f2..7fc2a67f95 100644 --- a/sao/src/view/form.js +++ b/sao/src/view/form.js @@ -1076,12 +1076,11 @@ function eval_pyson(value){ 'method': ( 'model.' + action.res_model + '.search_count'), 'params': [ - ['AND', domain, 0, tab_domain], 100, context], - }, Sao.Session.current_session, true, false).then( - value => { - this._set_count( - value, i, current, counter, - action.name, tab_domains); + ['AND', domain, tab_domain], 0, 100, context], + }, Sao.Session.current_session).then(value => { + this._set_count( + value, i, current, counter, + action.name, tab_domains); }); promesses.push(prm); }, this); @@ -1090,8 +1089,7 @@ function eval_pyson(value){ 'method': ( 'model.' + action.res_model + '.search_count'), 'params': [domain, 0, 100, context], - }, Sao.Session.current_session, true, false - ).then(value => { + }, Sao.Session.current_session).then(value => { this._set_count( value, 0, current, counter, action.name, tab_domains); diff --git a/tryton/tryton/common/common.py b/tryton/tryton/common/common.py index 1fcb9d4576..5c7a53e760 100644 --- a/tryton/tryton/common/common.py +++ b/tryton/tryton/common/common.py @@ -1014,10 +1014,6 @@ def process_exception(exception, *args, **kwargs): PLOCK.release() if args: return rpc_execute(*args) - elif exception.faultCode == str(int(HTTPStatus.REQUEST_TIMEOUT)): - message( - _("Request times out. Try again later."), - msg_type=Gtk.MessageType.ERROR) elif exception.faultCode == str(int(HTTPStatus.TOO_MANY_REQUESTS)): message( _('Too many requests. Try again later.'), diff --git a/tryton/tryton/common/selection.py b/tryton/tryton/common/selection.py index 3ad456a15c..a7e420165b 100644 --- a/tryton/tryton/common/selection.py +++ b/tryton/tryton/common/selection.py @@ -30,13 +30,10 @@ class SelectionMixin(object): and key not in self._values2selection): try: if self.attrs.get('selection_change_with'): - selection = RPCExecute( - 'model', self.model_name, selection, value, - process_exception=False) + selection = RPCExecute('model', self.model_name, selection, + value) else: - selection = RPCExecute( - 'model', self.model_name, selection, - process_exception=False) + selection = RPCExecute('model', self.model_name, selection) except RPCException: selection = [] self._values2selection[key] = selection diff --git a/tryton/tryton/gui/main.py b/tryton/tryton/gui/main.py index 1b979831b0..436fff2b4f 100644 --- a/tryton/tryton/gui/main.py +++ b/tryton/tryton/gui/main.py @@ -23,8 +23,7 @@ from tryton.common import RPCContextReload, RPCException, RPCExecute from tryton.common.cellrendererclickablepixbuf import ( CellRendererClickablePixbuf) from tryton.config import CONFIG, TRYTON_ICON, get_config_dir -from tryton.exceptions import ( - TrytonError, TrytonServerError, TrytonServerUnavailable) +from tryton.exceptions import TrytonError, TrytonServerUnavailable from tryton.gui.window import Window from tryton.jsonrpc import object_hook from tryton.pyson import PYSONDecoder @@ -376,7 +375,7 @@ class Main(Gtk.Application): def set_result(result): try: result = result() - except (RPCException, TrytonServerError): + except RPCException: result = [] if search_text != widget.get_text(): if callback: @@ -402,8 +401,7 @@ class Main(Gtk.Application): RPCExecute('model', 'ir.model', 'global_search', search_text, CONFIG['client.limit'], self.menu_screen.model_name, - context=self.menu_screen.context, callback=set_result, - process_exception=False) + context=self.menu_screen.context, callback=set_result) return False def changed(widget): diff --git a/tryton/tryton/gui/window/view_form/model/record.py b/tryton/tryton/gui/window/view_form/model/record.py index 2b58554d25..2888cd8d19 100644 --- a/tryton/tryton/gui/window/view_form/model/record.py +++ b/tryton/tryton/gui/window/view_form/model/record.py @@ -5,7 +5,6 @@ import logging import tryton.common as common from tryton.common import RPCException, RPCExecute from tryton.config import CONFIG -from tryton.exceptions import TrytonServerError from tryton.pyson import PYSONDecoder from . import field as fields @@ -678,9 +677,8 @@ class Record: try: res = RPCExecute( 'model', self.model_name, - 'autocomplete_' + fieldname, args, context=self.get_context(), - process_exception=False) - except (RPCException, TrytonServerError): + 'autocomplete_' + fieldname, args, context=self.get_context()) + except RPCException: # ensure res is a list res = [] self.autocompletion[fieldname] = res diff --git a/tryton/tryton/gui/window/view_form/screen/screen.py b/tryton/tryton/gui/window/view_form/screen/screen.py index 37208d5f21..c4331b772c 100644 --- a/tryton/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/tryton/gui/window/view_form/screen/screen.py @@ -21,7 +21,6 @@ from tryton.common import ( from tryton.common.domain_inversion import canonicalize from tryton.common.domain_parser import DomainParser from tryton.config import CONFIG -from tryton.exceptions import TrytonServerError from tryton.gui.window.infobar import InfoBar from tryton.gui.window.view_form.model.group import Group from tryton.gui.window.view_form.view import View @@ -309,9 +308,8 @@ class Screen: try: self.search_count = RPCExecute( 'model', self.model_name, 'search_count', - domain, 0, self.count_limit, context=context, - process_exception=False) - except (RPCException, TrytonServerError): + domain, 0, self.count_limit, context=context) + except RPCException: self.search_count = 0 else: self.search_count = len(ids) diff --git a/tryton/tryton/gui/window/view_form/view/form_gtk/state_widget.py b/tryton/tryton/gui/window/view_form/view/form_gtk/state_widget.py index 61e4a4a3f2..b4a5b57a8f 100644 --- a/tryton/tryton/gui/window/view_form/view/form_gtk/state_widget.py +++ b/tryton/tryton/gui/window/view_form/view/form_gtk/state_widget.py @@ -7,7 +7,6 @@ from gi.repository import Gtk import tryton.common as common from tryton.action import Action from tryton.config import CONFIG -from tryton.exceptions import TrytonServerError from tryton.pyson import PYSONDecoder @@ -188,16 +187,14 @@ class Link(StateMixin, Gtk.Button): ['AND', domain, tab_domain], 0, 100, context=context, callback=functools.partial( self._set_count, idx=i, current=self._current, - counter=counter, label=label), - process_exception=False) + counter=counter, label=label)) else: common.RPCExecute( 'model', action['res_model'], 'search_count', domain, 0, 100, context=context, callback=functools.partial( self._set_count, current=self._current, - counter=counter, label=label), - process_exception=False) + counter=counter, label=label)) def _set_count(self, value, idx=0, current=None, counter=None, label=''): if current != self._current or not self.get_parent(): @@ -207,7 +204,7 @@ class Link(StateMixin, Gtk.Button): if count > 99: count = '99+' counter[idx] = count - except (common.RPCException, TrytonServerError): + except common.RPCException: pass self._set_label_counter(label, counter) diff --git a/trytond/CHANGELOG b/trytond/CHANGELOG index c3fd64c3a8..5f9cd4d3c2 100644 --- a/trytond/CHANGELOG +++ b/trytond/CHANGELOG @@ -1,4 +1,3 @@ -* Add timeout parameter on RPC definitions * Add pairwise_longest tools * Add support for Python 3.12 * Support default values for autocomplete diff --git a/trytond/doc/ref/rpc.rst b/trytond/doc/ref/rpc.rst index 00dd3b0190..d7dc7c8277 100644 --- a/trytond/doc/ref/rpc.rst +++ b/trytond/doc/ref/rpc.rst @@ -4,7 +4,7 @@ RPC === -.. class:: RPC([readonly[, instantiate[, [decorator, result[, check_access[, unique[, fresh_session[, cache[, timeout]]]]]]]]]) +.. class:: RPC([readonly[, instantiate[, [decorator, result[, check_access[, unique[, fresh_session[, cache]]]]]]]]) Define the behavior of Remote Procedure Call. @@ -46,12 +46,6 @@ Instance attributes are: A :class:`RPCCache` instance to compute the cache duration for the answer. -.. attribute:: RPC.timeout - - The timeout in second for the call. - ``0`` or ``None`` means no timeout is applied. - Default is ``None``. - RPCCache -------- diff --git a/trytond/doc/topics/configuration.rst b/trytond/doc/topics/configuration.rst index de51013c7c..5c93712f69 100644 --- a/trytond/doc/topics/configuration.rst +++ b/trytond/doc/topics/configuration.rst @@ -271,13 +271,6 @@ The maximum size in bytes of an authenticated request (zero means no limit). Default: 2GB -timeout -~~~~~~~ - -The timeout in seconds before aborting requests that have their execution time -depending on the parameters. - -Default: ``60`` cache ----- diff --git a/trytond/trytond/backend/__init__.py b/trytond/trytond/backend/__init__.py index 6dde7d5b99..7218d63567 100644 --- a/trytond/trytond/backend/__init__.py +++ b/trytond/trytond/backend/__init__.py @@ -12,8 +12,7 @@ from trytond.config import config __all__ = [ 'name', 'Database', 'TableHandler', - 'DatabaseIntegrityError', 'DatabaseDataError', 'DatabaseOperationalError', - 'DatabaseTimeoutError'] + 'DatabaseIntegrityError', 'DatabaseDataError', 'DatabaseOperationalError'] name = urllib.parse.urlparse(config.get('database', 'uri', default='')).scheme @@ -35,5 +34,4 @@ Database = _module.Database DatabaseIntegrityError = _module.DatabaseIntegrityError DatabaseDataError = _module.DatabaseDataError DatabaseOperationalError = _module.DatabaseOperationalError -DatabaseTimeoutError = _module.DatabaseTimeoutError TableHandler = _module.TableHandler diff --git a/trytond/trytond/backend/database.py b/trytond/trytond/backend/database.py index 9915bd76c3..4da335ef9a 100644 --- a/trytond/trytond/backend/database.py +++ b/trytond/trytond/backend/database.py @@ -6,7 +6,6 @@ from sql import For DatabaseIntegrityError = None DatabaseOperationalError = None -DatabaseTimeoutError = None SQLType = namedtuple('SQLType', 'base type') @@ -27,8 +26,7 @@ class DatabaseInterface(object): def connect(self): raise NotImplementedError - def get_connection( - self, autocommit=False, readonly=False, statement_timeout=None): + def get_connection(self, autocommit=False, readonly=False): raise NotImplementedError def put_connection(self, connection, close=False): diff --git a/trytond/trytond/backend/postgresql/__init__.py b/trytond/trytond/backend/postgresql/__init__.py index 05a01ca5be..98083d06a7 100644 --- a/trytond/trytond/backend/postgresql/__init__.py +++ b/trytond/trytond/backend/postgresql/__init__.py @@ -3,10 +3,9 @@ from .database import ( Database, DatabaseDataError, DatabaseIntegrityError, - DatabaseOperationalError, DatabaseTimeoutError) + DatabaseOperationalError) from .table import TableHandler __all__ = [ Database, TableHandler, - DatabaseIntegrityError, DatabaseDataError, DatabaseOperationalError, - DatabaseTimeoutError] + DatabaseIntegrityError, DatabaseDataError, DatabaseOperationalError] diff --git a/trytond/trytond/backend/postgresql/database.py b/trytond/trytond/backend/postgresql/database.py index 5cb21347d4..7ffdd04ab0 100644 --- a/trytond/trytond/backend/postgresql/database.py +++ b/trytond/trytond/backend/postgresql/database.py @@ -26,7 +26,6 @@ from psycopg2 import DataError as DatabaseDataError from psycopg2 import IntegrityError as DatabaseIntegrityError from psycopg2 import OperationalError as DatabaseOperationalError from psycopg2 import ProgrammingError -from psycopg2.errors import QueryCanceled as DatabaseTimeoutError from psycopg2.extras import register_default_json, register_default_jsonb from sql import Cast, Flavor, For, Table from sql.conditionals import Coalesce @@ -39,8 +38,7 @@ from trytond.tools.gevent import is_gevent_monkey_patched __all__ = [ 'Database', - 'DatabaseIntegrityError', 'DatabaseDataError', 'DatabaseOperationalError', - 'DatabaseTimeoutError'] + 'DatabaseIntegrityError', 'DatabaseDataError', 'DatabaseOperationalError'] logger = logging.getLogger(__name__) @@ -256,8 +254,7 @@ class Database(DatabaseInterface): def connect(self): return self - def get_connection( - self, autocommit=False, readonly=False, statement_timeout=None): + def get_connection(self, autocommit=False, readonly=False): retry = max(config.getint('database', 'retry'), _maxconn) for count in range(retry, -1, -1): try: @@ -277,13 +274,8 @@ class Database(DatabaseInterface): isolation_level=ISOLATION_LEVEL_REPEATABLE_READ, readonly=readonly, autocommit=autocommit) - with conn.cursor() as cur: - if statement_timeout: - cur.execute('SET statement_timeout=%s' % - (statement_timeout * 1000)) - else: - # Detect disconnection - cur.execute('SELECT 1') + # Detect disconnection + conn.cursor().execute('SELECT 1') except DatabaseOperationalError: self._connpool.putconn(conn, close=True) continue @@ -291,7 +283,6 @@ class Database(DatabaseInterface): return conn def put_connection(self, connection, close=False): - connection.reset() self._connpool.putconn(connection, close=close) def close(self): diff --git a/trytond/trytond/backend/sqlite/__init__.py b/trytond/trytond/backend/sqlite/__init__.py index 05a01ca5be..98083d06a7 100644 --- a/trytond/trytond/backend/sqlite/__init__.py +++ b/trytond/trytond/backend/sqlite/__init__.py @@ -3,10 +3,9 @@ from .database import ( Database, DatabaseDataError, DatabaseIntegrityError, - DatabaseOperationalError, DatabaseTimeoutError) + DatabaseOperationalError) from .table import TableHandler __all__ = [ Database, TableHandler, - DatabaseIntegrityError, DatabaseDataError, DatabaseOperationalError, - DatabaseTimeoutError] + DatabaseIntegrityError, DatabaseDataError, DatabaseOperationalError] diff --git a/trytond/trytond/backend/sqlite/database.py b/trytond/trytond/backend/sqlite/database.py index a484d158da..51fd17e616 100644 --- a/trytond/trytond/backend/sqlite/database.py +++ b/trytond/trytond/backend/sqlite/database.py @@ -29,8 +29,7 @@ from trytond.transaction import Transaction __all__ = [ 'Database', - 'DatabaseIntegrityError', 'DatabaseDataError', 'DatabaseOperationalError', - 'DatabaseTimeoutError'] + 'DatabaseIntegrityError', 'DatabaseDataError', 'DatabaseOperationalError'] logger = logging.getLogger(__name__) _default_name = config.get('database', 'default_name', default=':memory:') @@ -40,10 +39,6 @@ class DatabaseDataError(DatabaseError): pass -class DatabaseTimeoutError(Exception): - pass - - class SQLiteExtract(Function): __slots__ = () _function = 'EXTRACT' @@ -450,8 +445,7 @@ class Database(DatabaseInterface): db_uri = urllib.parse.urlunparse(db_uri) return db_uri.replace('sqlite', 'file', 1) - def get_connection( - self, autocommit=False, readonly=False, statement_timeout=None): + def get_connection(self, autocommit=False, readonly=False): if self._conn is None: self.connect() if autocommit: diff --git a/trytond/trytond/config.py b/trytond/trytond/config.py index e6e9ab23d9..3aebf6c6c9 100644 --- a/trytond/trytond/config.py +++ b/trytond/trytond/config.py @@ -70,7 +70,6 @@ class TrytonConfigParser(configparser.ConfigParser): self.set('request', 'max_size', str(2 * 1024 * 1024)) self.set('request', 'max_size_authenticated', str(2 * 1024 * 1024 * 1024)) - self.set('request', 'timeout', str(60)) self.add_section('cache') self.set('cache', 'transaction', '10') self.set('cache', 'model', '200') diff --git a/trytond/trytond/ir/model.py b/trytond/trytond/ir/model.py index d8162f7d0e..2e7ecc0320 100644 --- a/trytond/trytond/ir/model.py +++ b/trytond/trytond/ir/model.py @@ -13,7 +13,6 @@ from sql.conditionals import Case from sql.operators import Equal from trytond.cache import Cache -from trytond.config import config from trytond.i18n import gettext from trytond.model import ( DeactivableMixin, EvalEnvironment, Exclude, Index, ModelSingleton, @@ -32,7 +31,6 @@ from trytond.wizard import Button, StateAction, StateView, Wizard from .resource import ResourceAccessMixin logger = logging.getLogger(__name__) -_request_timeout = config.getint('request', 'timeout', default=0) class ConditionError(ValidationError): @@ -79,7 +77,7 @@ class Model(ModelSQL, ModelView): 'list_history': RPC(), 'get_notification': RPC(), 'get_names': RPC(), - 'global_search': RPC(timeout=_request_timeout), + 'global_search': RPC(), }) @classmethod diff --git a/trytond/trytond/model/modelstorage.py b/trytond/trytond/model/modelstorage.py index be7bcbd13c..048828fe67 100644 --- a/trytond/trytond/model/modelstorage.py +++ b/trytond/trytond/model/modelstorage.py @@ -39,7 +39,6 @@ _cache_count_timeout = config.getint( 'cache', 'count_timeout', default=60 * 60 * 24) _cache_count_clear = config.getint( 'cache', 'count_clear', default=1000) -_request_timeout = config.getint('request', 'timeout', default=0) def local_cache(Model, transaction=None): @@ -137,15 +136,11 @@ class ModelStorage(Model): 'delete': RPC(readonly=False, instantiate=0), 'copy': RPC(readonly=False, instantiate=0, unique=False, result=lambda r: list(map(int, r))), - 'search': RPC( - result=lambda r: list(map(int, r)), - timeout=_request_timeout), - 'search_count': RPC(timeout=_request_timeout), - 'search_read': RPC(timeout=_request_timeout), - 'resources': RPC( - instantiate=0, unique=False, - timeout=_request_timeout), - 'export_data_domain': RPC(timeout=_request_timeout), + 'search': RPC(result=lambda r: list(map(int, r))), + 'search_count': RPC(), + 'search_read': RPC(), + 'resources': RPC(instantiate=0, unique=False), + 'export_data_domain': RPC(), 'export_data': RPC(instantiate=0, unique=False), 'import_data': RPC(readonly=False), }) diff --git a/trytond/trytond/protocols/dispatcher.py b/trytond/trytond/protocols/dispatcher.py index 9185cf7357..d750ba0558 100644 --- a/trytond/trytond/protocols/dispatcher.py +++ b/trytond/trytond/protocols/dispatcher.py @@ -184,8 +184,7 @@ def _dispatch(request, pool, *args, **kwargs): if count: time.sleep(0.02 * (retry - count)) with Transaction().start( - pool.database_name, user, - readonly=rpc.readonly, timeout=rpc.timeout, + pool.database_name, user, readonly=rpc.readonly, **transaction_extras) as transaction: try: c_args, c_kwargs, transaction.context, transaction.timestamp \ @@ -208,9 +207,6 @@ def _dispatch(request, pool, *args, **kwargs): transaction.tasks.clear() e.fix(transaction_extras) continue - except backend.DatabaseTimeoutError: - logger.warning(log_message, *log_args, exc_info=True) - abort(HTTPStatus.REQUEST_TIMEOUT) except backend.DatabaseOperationalError: if count < retry and not rpc.readonly: transaction.rollback() diff --git a/trytond/trytond/rpc.py b/trytond/trytond/rpc.py index 727f8f1f91..c1bd427e9d 100644 --- a/trytond/trytond/rpc.py +++ b/trytond/trytond/rpc.py @@ -21,12 +21,11 @@ class RPC(object): __slots__ = ( 'readonly', 'instantiate', 'decorator', 'result', - 'check_access', 'fresh_session', 'unique', 'cache', 'timeout') + 'check_access', 'fresh_session', 'unique', 'cache') def __init__( self, readonly=True, instantiate=None, decorator=None, result=None, - check_access=True, fresh_session=False, unique=True, cache=None, - timeout=None): + check_access=True, fresh_session=False, unique=True, cache=None): self.readonly = readonly self.instantiate = instantiate self.decorator = decorator @@ -41,7 +40,6 @@ class RPC(object): if not isinstance(cache, RPCCache): cache = RPCCache(**cache) self.cache = cache - self.timeout = timeout def convert(self, obj, *args, **kwargs): args = list(args) diff --git a/trytond/trytond/tests/test_transaction.py b/trytond/trytond/tests/test_transaction.py index 7b63464b44..24d004fd8f 100644 --- a/trytond/trytond/tests/test_transaction.py +++ b/trytond/trytond/tests/test_transaction.py @@ -3,7 +3,6 @@ import unittest from unittest.mock import Mock -from trytond import backend from trytond.tests.test_tryton import CONTEXT, DB_NAME, USER, activate_module from trytond.transaction import Transaction @@ -122,26 +121,3 @@ class TransactionTestCase(unittest.TestCase): dm.tpc_vote.assert_not_called() dm.tpc_abort.assert_called_once_with(transaction) dm.tpc_finish.assert_not_called() - - @unittest.skipUnless(backend.name == 'postgresql', "Test pg_settings") - def test_postgresl_statement_timeout(self): - get_timeout = ( - "SELECT setting FROM pg_settings " - "WHERE name='statement_timeout'") - - with Transaction().start(DB_NAME, USER) as transaction: - cursor = transaction.connection.cursor() - cursor.execute(get_timeout) - self.assertEqual('0', cursor.fetchone()[0]) - - with Transaction().start(DB_NAME, USER, timeout=1) as transaction: - cursor = transaction.connection.cursor() - cursor.execute(get_timeout) - self.assertEqual('1000', cursor.fetchone()[0]) - - @unittest.skipUnless(backend.name == 'postgresql', "Use pg_sleep") - def test_postgresql_statement_timeout_exception(self): - with self.assertRaises(backend.DatabaseTimeoutError): - with Transaction().start(DB_NAME, USER, timeout=1) as transaction: - cursor = transaction.connection.cursor() - cursor.execute("SELECT pg_sleep(2)") diff --git a/trytond/trytond/transaction.py b/trytond/trytond/transaction.py index ed179c7316..993c391cbf 100644 --- a/trytond/trytond/transaction.py +++ b/trytond/trytond/transaction.py @@ -159,7 +159,7 @@ class Transaction(object): return cache def start(self, database_name, user, readonly=False, context=None, - close=False, autocommit=False, timeout=None, **extras): + close=False, autocommit=False, **extras): ''' Start transaction ''' @@ -197,7 +197,7 @@ class Transaction(object): if count: time.sleep(0.002 * (_retry - count)) self.connection = database.get_connection(readonly=readonly, - autocommit=autocommit, statement_timeout=timeout) + autocommit=autocommit) try: lock_tables = extras.get('_lock_tables', []) for table in lock_tables: