Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-aiomisc for openSUSE:Factory checked in at 2023-05-29 22:48:06 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-aiomisc (Old) and /work/SRC/openSUSE:Factory/.python-aiomisc.new.1533 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-aiomisc" Mon May 29 22:48:06 2023 rev:3 rq:1089593 version:17.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-aiomisc/python-aiomisc.changes 2023-05-20 17:23:42.197572990 +0200 +++ /work/SRC/openSUSE:Factory/.python-aiomisc.new.1533/python-aiomisc.changes 2023-05-29 22:48:20.750492191 +0200 @@ -1,0 +2,25 @@ +Mon May 29 14:36:12 UTC 2023 - Dirk Müller <dmuel...@suse.com> + +- update to 16.3: + * Use `poem-plugins` for creating `aiomisc/version.py` file and + bump version when publishing. + * some non-public imports might be broken, mainly typing, and + the `aiomisc.io` module + * Buffered log handler in `aiomisc.log`, is now correct + finalize when an entrypoint stops. + * Support stream compression for opening files with: + * `GZIP` - compressed files + * `LZMA` - compressed files + * `BZ2` - compressed files + * Added `aiohttp_asgi` objects to `__all__` in + `aiomisc.service.asgi` + * `aiomisc.Service` subclasses is now can be serialized with + `pickle` + * Improves typing for: + * `aiomisc.io` + * `aiomisc.pool` + * `aiomisc.service.udp` + * `aiomisc.worker_pool.WorkerPool` + * Improve documentation + +------------------------------------------------------------------- Old: ---- aiomisc-17.2.2.tar.gz New: ---- aiomisc-17.3.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-aiomisc.spec ++++++ --- /var/tmp/diff_new_pack.bUwNTz/_old 2023-05-29 22:48:21.254495206 +0200 +++ /var/tmp/diff_new_pack.bUwNTz/_new 2023-05-29 22:48:21.262495254 +0200 @@ -18,14 +18,13 @@ %{?sle15_python_module_pythons} Name: python-aiomisc -Version: 17.2.2 +Version: 17.3.0 Release: 0 Summary: Miscellaneous utils for asyncio License: MIT URL: https://github.com/aiokitchen/aiomisc Source: https://files.pythonhosted.org/packages/source/a/aiomisc/aiomisc-%{version}.tar.gz Source1: https://raw.githubusercontent.com/aiokitchen/aiomisc/v17.2/COPYING -BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros Requires: python-colorlog >= 6.0 ++++++ aiomisc-17.2.2.tar.gz -> aiomisc-17.3.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aiomisc-17.2.2/PKG-INFO new/aiomisc-17.3.0/PKG-INFO --- old/aiomisc-17.2.2/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 +++ new/aiomisc-17.3.0/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: aiomisc -Version: 17.2.2 +Version: 17.3.0 Summary: aiomisc - miscellaneous utils for asyncio Home-page: https://github.com/aiokitchen/aiomisc License: MIT @@ -29,12 +29,6 @@ Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 -Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.10 -Classifier: Programming Language :: Python :: 3.11 -Classifier: Programming Language :: Python :: 3.7 -Classifier: Programming Language :: Python :: 3.8 -Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Topic :: Internet Classifier: Topic :: Internet :: WWW/HTTP diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aiomisc-17.2.2/aiomisc/compat.py new/aiomisc-17.3.0/aiomisc/compat.py --- old/aiomisc-17.2.2/aiomisc/compat.py 2023-05-01 09:49:39.496255000 +0200 +++ new/aiomisc-17.3.0/aiomisc/compat.py 2023-05-24 11:12:53.723018400 +0200 @@ -2,6 +2,7 @@ import logging import os import socket +import sys from typing import Optional from ._context_vars import EVENT_LOOP @@ -17,12 +18,16 @@ def time_ns() -> int: return int(time() * 1000000000) - try: from typing import final except ImportError: from typing_extensions import final # type: ignore +if sys.version_info >= (3, 10): + from typing import ParamSpec +else: + from typing_extensions import ParamSpec + class EventLoopMixin: __slots__ = "_loop", @@ -77,6 +82,7 @@ __all__ = ( "EventLoopMixin", + "ParamSpec", "event_loop_policy", "final", "get_current_loop", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aiomisc-17.2.2/aiomisc/entrypoint.py new/aiomisc-17.3.0/aiomisc/entrypoint.py --- old/aiomisc-17.2.2/aiomisc/entrypoint.py 2023-05-01 09:49:39.496255000 +0200 +++ new/aiomisc-17.3.0/aiomisc/entrypoint.py 2023-05-24 11:12:53.723018400 +0200 @@ -3,6 +3,7 @@ import os import signal import sys +import threading from concurrent.futures import Executor from typing import ( Any, Callable, Coroutine, FrozenSet, MutableSet, Optional, Set, Tuple, @@ -31,6 +32,10 @@ asyncio_current_task = asyncio.current_task +def is_main_thread() -> bool: + return threading.current_thread() == threading.main_thread() + + def _get_env_bool(name: str, default: str) -> bool: enable_variants = {"1", "enable", "enabled", "on", "true", "yes"} return os.getenv(name, default).lower() in enable_variants @@ -143,10 +148,9 @@ log_config: bool = DEFAULT_AIOMISC_LOG_CONFIG, policy: asyncio.AbstractEventLoopPolicy = event_loop_policy, debug: bool = DEFAULT_AIOMISC_DEBUG, - catch_signals: Tuple[int, ...] = (signal.SIGINT, signal.SIGTERM), + catch_signals: Optional[Tuple[int, ...]] = None, shutdown_timeout: Union[int, float] = AIOMISC_SHUTDOWN_TIMEOUT, ): - """ Creates a new Entrypoint :param debug: set debug to event-loop @@ -173,9 +177,14 @@ self._thread_pool: Optional[ExecutorType] = None self._closing: Optional[asyncio.Event] = None + if catch_signals is None and is_main_thread(): + # Apply default catch signals only if the entrypoint is creating + # in only in main thread + catch_signals = (signal.SIGINT, signal.SIGTERM) + self._signal_handlers = [ OSSignalHandler(sig, self._on_interrupt_callback) - for sig in catch_signals + for sig in catch_signals or () ] self.catch_signals = catch_signals diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aiomisc-17.2.2/aiomisc/process_pool.py new/aiomisc-17.3.0/aiomisc/process_pool.py --- old/aiomisc-17.2.2/aiomisc/process_pool.py 2023-05-01 09:49:39.496255000 +0200 +++ new/aiomisc-17.3.0/aiomisc/process_pool.py 2023-05-24 11:12:53.723018400 +0200 @@ -1,20 +1,11 @@ import asyncio -from concurrent.futures import Executor -from multiprocessing import Pool, cpu_count -from typing import Any, Callable, Set, Tuple, TypeVar +from concurrent.futures import Future +from concurrent.futures import ProcessPoolExecutor as ProcessPoolExecutorBase +from multiprocessing import cpu_count +from typing import Any from .compat import EventLoopMixin from .counters import Statistic -from .utils import set_exception - - -T = TypeVar("T") -FuturesSet = Set[asyncio.Future] -_CreateFutureType = Tuple[ - Callable[[T], None], - Callable[[T], None], - asyncio.Future, -] class ProcessPoolStatistic(Statistic): @@ -26,81 +17,39 @@ sum_time: float -class ProcessPoolExecutor(Executor, EventLoopMixin): - __slots__ = ( - "__futures", "__pool", "_statistic", - ) + EventLoopMixin.__slots__ - +class ProcessPoolExecutor(ProcessPoolExecutorBase, EventLoopMixin): DEFAULT_MAX_WORKERS = max((cpu_count(), 4)) def __init__(self, max_workers: int = DEFAULT_MAX_WORKERS, **kwargs: Any): - self.__futures: FuturesSet = set() - self.__pool = Pool(processes=max_workers, **kwargs) + super().__init__(max_workers=max_workers, **kwargs) self._statistic = ProcessPoolStatistic() self._statistic.processes = max_workers - def _create_future(self) -> _CreateFutureType: - future = self.loop.create_future() # type: asyncio.Future - - self.__futures.add(future) - future.add_done_callback(self.__futures.discard) - - start_time = self.loop.time() - - def callback(result: T) -> None: + def _statistic_callback( + self, + future: Future, + start_time: float, + loop: asyncio.AbstractEventLoop, + ) -> None: + if future.exception(): + self._statistic.error += 1 + else: self._statistic.success += 1 - self._statistic.done += 1 - self._statistic.sum_time += self.loop.time() - start_time - self.loop.call_soon_threadsafe(future.set_result, result) + self._statistic.done += 1 + self._statistic.sum_time += loop.time() - start_time - def errorback(exc: T) -> None: - self._statistic.error += 1 - self._statistic.done += 1 - self._statistic.sum_time += self.loop.time() - start_time - self.loop.call_soon_threadsafe(future.set_exception, exc) - - return callback, errorback, future - - def submit( # type: ignore - self, fn: Callable[..., T], - *args: Any, **kwargs: Any, - ) -> asyncio.Future: + def submit(self, *args: Any, **kwargs: Any) -> Future: """ Submit blocking function to the pool """ - if fn is None or not callable(fn): - raise ValueError("First argument must be callable") - - callback, errorback, future = self._create_future() - - self.__pool.apply_async( - fn, - args=args, - kwds=kwargs, - callback=callback, - error_callback=errorback, - ) - + loop = asyncio.get_running_loop() + start_time = loop.time() + future = super().submit(*args, **kwargs) self._statistic.submitted += 1 + future.add_done_callback( + lambda f: self._statistic_callback(f, start_time, loop), + ) return future - # noinspection PyMethodOverriding - def shutdown( - self, wait: bool = True, cancel_futures: bool = False, - ) -> None: - - if not self.__pool: - return - - self.__pool.terminate() - - if cancel_futures: - set_exception(self.__futures, asyncio.CancelledError()) - - self.__pool.close() - - if wait: - self.__pool.join() - def __del__(self) -> None: self.shutdown() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aiomisc-17.2.2/aiomisc/thread_pool.py new/aiomisc-17.3.0/aiomisc/thread_pool.py --- old/aiomisc-17.2.2/aiomisc/thread_pool.py 2023-05-01 09:49:39.496255000 +0200 +++ new/aiomisc-17.3.0/aiomisc/thread_pool.py 2023-05-24 11:12:53.727018400 +0200 @@ -16,10 +16,12 @@ ) from ._context_vars import EVENT_LOOP +from .compat import ParamSpec from .counters import Statistic from .iterator_wrapper import IteratorWrapper +P = ParamSpec("P") T = TypeVar("T") F = TypeVar("F", bound=Callable[..., Any]) log = logging.getLogger(__name__) @@ -252,8 +254,8 @@ def threaded( - func: Callable[..., T], -) -> Callable[..., Awaitable[T]]: + func: Callable[P, T], +) -> Callable[P, Awaitable[T]]: if asyncio.iscoroutinefunction(func): raise TypeError("Can not wrap coroutine") @@ -262,7 +264,7 @@ @wraps(func) def wrap( - *args: Any, **kwargs: Any, + *args: P.args, **kwargs: P.kwargs, ) -> Awaitable[T]: return run_in_executor(func=func, args=args, kwargs=kwargs) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aiomisc-17.2.2/aiomisc/version.py new/aiomisc-17.3.0/aiomisc/version.py --- old/aiomisc-17.2.2/aiomisc/version.py 2023-05-01 09:50:16.934488800 +0200 +++ new/aiomisc-17.3.0/aiomisc/version.py 2023-05-24 11:13:34.774950000 +0200 @@ -2,5 +2,5 @@ # BY: poem-plugins "git" plugin # NEVER EDIT THIS FILE MANUALLY -version_info = (17, 2, 2) -__version__ = "17.2.2" +version_info = (17, 3, 0) +__version__ = "17.3.0" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aiomisc-17.2.2/aiomisc/worker_pool.py new/aiomisc-17.3.0/aiomisc/worker_pool.py --- old/aiomisc-17.2.2/aiomisc/worker_pool.py 2023-05-01 09:49:39.496255000 +0200 +++ new/aiomisc-17.3.0/aiomisc/worker_pool.py 2023-05-24 11:12:53.727018400 +0200 @@ -80,7 +80,7 @@ process.kill() @threaded - def __create_supervisor(self, *identity: str) -> Popen: + def __create_supervisor(self, *identity: bytes) -> Popen: if self.__closing: raise RuntimeError("Pool closed") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/aiomisc-17.2.2/pyproject.toml new/aiomisc-17.3.0/pyproject.toml --- old/aiomisc-17.2.2/pyproject.toml 2023-05-01 09:50:16.934488800 +0200 +++ new/aiomisc-17.3.0/pyproject.toml 2023-05-24 11:13:34.774950000 +0200 @@ -1,7 +1,7 @@ [tool.poetry] name = "aiomisc" # This is a dummy version which will be rewritten with poem-plugins -version = "17.2.2" +version = "17.3.0" description = "aiomisc - miscellaneous utils for asyncio" authors = ["Dmitry Orlov <m...@mosquito.su>"] readme = "README.rst" @@ -68,7 +68,6 @@ uvloop = { version = ">=0.14, <1", optional = true } [tool.poetry.group.dev.dependencies] -aiocontextvars = "0.2.2" aiohttp = ">3" aiohttp-asgi = "~0.5.2" aiomisc-pytest = "^1.0.8"