Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-aiorpcX for openSUSE:Factory checked in at 2021-04-23 17:50:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-aiorpcX (Old) and /work/SRC/openSUSE:Factory/.python-aiorpcX.new.12324 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-aiorpcX" Fri Apr 23 17:50:40 2021 rev:7 rq:887912 version:0.18.7 Changes: -------- --- /work/SRC/openSUSE:Factory/python-aiorpcX/python-aiorpcX.changes 2020-04-25 20:36:46.483067585 +0200 +++ /work/SRC/openSUSE:Factory/.python-aiorpcX.new.12324/python-aiorpcX.changes 2021-04-23 17:50:57.062827743 +0200 @@ -1,0 +2,11 @@ +Mon Apr 19 06:50:31 UTC 2021 - Jiri Slaby <[email protected]> + +- update to 0.18.7 + * don't wait for tasks to cancel if exiting by exception + * Fix tests for Python3.8 (we reenable them) + * Merge pull request #34 + * SOCKS: Fix random auth on Python 3.8+ + * Merge pull request #33 + * session: add method on_disconnect_due_to_excessive_session_cost + +------------------------------------------------------------------- Old: ---- 0.18.4.tar.gz New: ---- 0.18.7.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-aiorpcX.spec ++++++ --- /var/tmp/diff_new_pack.6QzYbs/_old 2021-04-23 17:50:57.466828437 +0200 +++ /var/tmp/diff_new_pack.6QzYbs/_new 2021-04-23 17:50:57.470828444 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-aiorpcX # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %define skip_python2 1 %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-aiorpcX -Version: 0.18.4 +Version: 0.18.7 Release: 0 Summary: Generic async RPC implementation, including JSON-RPC License: MIT @@ -62,8 +62,8 @@ SKIP_TESTS="test_auto_detect_address_failure or test_create_connection_resolve_good" # test_slow_connection_aborted - randomly fails, out of 10 runs 6 fails SKIP_TESTS="$SKIP_TESTS or test_slow_connection_aborted" -# Fails with Python 3.8 gh#kyuupichan/aiorpcX#30 -SKIP_TESTS="$SKIP_TESTS or test_nested_context_timeout2 or test_nested_context_timeout3 or test_handler_invocation or test_random" +# test_cancel_remaining_on_group_with_stubborn_task - cannot import create_task -- why? (A new test from 82048a219aac.) +SKIP_TESTS="$SKIP_TESTS or test_cancel_remaining_on_group_with_stubborn_task" %pytest -k "not ($SKIP_TESTS)" %files %{python_files} ++++++ 0.18.4.tar.gz -> 0.18.7.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aiorpcX-0.18.4/aiorpcx/__init__.py new/aiorpcX-0.18.7/aiorpcx/__init__.py --- old/aiorpcX-0.18.4/aiorpcx/__init__.py 2019-11-20 19:02:43.000000000 +0100 +++ new/aiorpcX-0.18.7/aiorpcx/__init__.py 2021-03-10 01:10:28.000000000 +0100 @@ -8,7 +8,7 @@ from .websocket import * -_version_str = '0.18.4' +_version_str = '0.18.7' _version = tuple(int(part) for part in _version_str.split('.')) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aiorpcX-0.18.4/aiorpcx/curio.py new/aiorpcX-0.18.7/aiorpcx/curio.py --- old/aiorpcX-0.18.4/aiorpcx/curio.py 2019-11-20 19:02:43.000000000 +0100 +++ new/aiorpcX-0.18.7/aiorpcx/curio.py 2021-03-10 01:10:28.000000000 +0100 @@ -205,20 +205,33 @@ if task is None or not errored(task): return finally: - await self.cancel_remaining() + # Cancel everything but don't wait as cancellation can be ignored and our + # exception could be e.g. a timeout. + await self.cancel_remaining(blocking=False) if errored(task): raise task.exception() - async def cancel_remaining(self): - '''Cancel all remaining tasks.''' + async def cancel_remaining(self, blocking=True): + '''Cancel all remaining tasks. Wait for them to complete if blocking is True.''' self._closed = True - task_list = list(self._pending) - for task in task_list: + for task in self._pending: task.cancel() - for task in task_list: - with suppress(CancelledError): - await task + + if blocking and self._pending: + def pop_task(task): + unfinished.remove(task) + if not unfinished: + all_done.set() + + unfinished = self._pending.copy() + for task in unfinished: + task.add_done_callback(pop_task) + all_done = Event() + await all_done.wait() + else: + # So loop processes cancellations + await sleep(0) def closed(self): return self._closed diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aiorpcX-0.18.4/aiorpcx/session.py new/aiorpcX-0.18.7/aiorpcx/session.py --- old/aiorpcX-0.18.4/aiorpcx/session.py 2019-11-20 19:02:43.000000000 +0100 +++ new/aiorpcX-0.18.7/aiorpcx/session.py 2021-03-10 01:10:28.000000000 +0100 @@ -184,6 +184,12 @@ if abs(self.cost - self._cost_last) > 100: self.recalc_concurrency() + def on_disconnect_due_to_excessive_session_cost(self): + '''Called just before disconnecting from the session, if it was consuming too + much resources. + ''' + pass + def recalc_concurrency(self): '''Call to recalculate sleeps and concurrency for the session. Called automatically if cost has drifted significantly. Otherwise can be called at regular intervals if @@ -306,6 +312,7 @@ self.logger.info(f'incoming request timed out after {timeout} secs') self._bump_errors() except ExcessiveSessionCostError: + self.on_disconnect_due_to_excessive_session_cost() await self.close() except CancelledError: raise @@ -474,6 +481,7 @@ result = e.args[0] disconnect = True except ExcessiveSessionCostError: + self.on_disconnect_due_to_excessive_session_cost() result = RPCError(JSONRPC.EXCESSIVE_RESOURCE_USAGE, 'excessive resource usage') disconnect = True except CancelledError: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aiorpcX-0.18.4/aiorpcx/socks.py new/aiorpcX-0.18.7/aiorpcx/socks.py --- old/aiorpcX-0.18.4/aiorpcx/socks.py 2019-11-20 19:02:43.000000000 +0100 +++ new/aiorpcX-0.18.7/aiorpcx/socks.py 2021-03-10 01:10:28.000000000 +0100 @@ -45,7 +45,7 @@ # Random authentication is useful when used with Tor for stream isolation. class SOCKSRandomAuth(SOCKSUserAuth): - def __getitem__(self, key): + def __getattribute__(self, key): return secrets.token_hex(32) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aiorpcX-0.18.4/docs/changelog.rst new/aiorpcX-0.18.7/docs/changelog.rst --- old/aiorpcX-0.18.4/docs/changelog.rst 2019-11-20 19:02:43.000000000 +0100 +++ new/aiorpcX-0.18.7/docs/changelog.rst 2021-03-10 01:10:28.000000000 +0100 @@ -5,6 +5,11 @@ for a 1.0 release in the coming months. +Version 0.18.7 (10 Mar 2021) +---------------------------- + +* join() waiting when cancelled fix, also issue #37 + Version 0.18.4 (20 Nov 2019) ---------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aiorpcX-0.18.4/tests/test_curio.py new/aiorpcX-0.18.7/tests/test_curio.py --- old/aiorpcX-0.18.4/tests/test_curio.py 2019-11-20 19:02:43.000000000 +0100 +++ new/aiorpcX-0.18.7/tests/test_curio.py 2021-03-10 01:10:28.000000000 +0100 @@ -553,7 +553,7 @@ try: async with timeout_after(0.01) as ta: await coro2() - except Exception as e: + except (Exception, CancelledError) as e: assert isinstance(e, TaskTimeout) else: assert False @@ -585,7 +585,7 @@ async def parent(): try: await timeout_after(0.001, coro2) - except Exception as e: + except (Exception, CancelledError) as e: assert isinstance(e, TaskTimeout) else: assert False @@ -1397,6 +1397,60 @@ assert g.completed is None [email protected] +async def test_timeout_on_join_with_stubborn_task(): + evt = Event() + + async def ignore_cancellation(): + while True: + try: + await evt.wait() + break + except CancelledError as e: + pass + + + async with ignore_after(0.05): + async with TaskGroup() as g: + t = await g.spawn(ignore_cancellation) + # Clean teardown + evt.set() + + +# See https://github.com/kyuupichan/aiorpcX/issues/37 [email protected] +async def test_cancel_remaining_on_group_with_stubborn_task(): + evt = Event() + + async def run_forever(): + while True: + try: + await evt.wait() + break + except CancelledError as e: + pass + + async def run_group(): + async with group: + await group.spawn(run_forever) + + from asyncio import create_task + + group = TaskGroup() + create_task(run_group()) + await sleep(0.01) + + try: + async with timeout_after(0.01): + await group.cancel_remaining() + except TaskTimeout: + pass + + # Clean teardown + evt.set() + await sleep(0.001) + + def test_TaskTimeout_str(): t = TaskTimeout(0.5) assert str(t) == 'task timed out after 0.5s' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aiorpcX-0.18.4/tests/test_jsonrpc.py new/aiorpcX-0.18.7/tests/test_jsonrpc.py --- old/aiorpcX-0.18.4/tests/test_jsonrpc.py 2019-11-20 19:02:43.000000000 +0100 +++ new/aiorpcX-0.18.7/tests/test_jsonrpc.py 2021-03-10 01:10:28.000000000 +0100 @@ -1,3 +1,5 @@ +import sys + from itertools import chain, combinations, count import json import pytest @@ -1122,17 +1124,22 @@ invocation = handler_invocation(handler, request) assert invocation() == result - bad_requests = ( + if sys.version_info < (3, 8): + powb_request = (Request('powb', {"x": 2, "y": 3}), 'cannot be called') + else: + powb_request = (Request('powb', {"x": 2, "y": 3}), 'requires parameters') + + bad_requests = [ (Request('missing_method', []), 'unknown method'), (Request('add_many', []), 'requires 1'), (Request('add_many', {'first': 1, 'values': []}), 'values'), - (Request('powb', {"x": 2, "y": 3}), 'cannot be called'), + powb_request, (Request('echo_2', ['ping', 'pong']), 'at most 1'), (Request('echo_2', {'first': 1, 'second': 8, '3rd': 1}), '3rd'), (Request('kwargs', []), 'requires 1'), (Request('kwargs', {'end': 4}), "start"), (Request('kwargs', {'start': 3, 'end': 1, '3rd': 1}), '3rd'), - ) + ] for request, text in bad_requests: with pytest.raises(RPCError) as e:
