This document describes the changes that have occurred in the releases of this library.
The story is not written from the very beginning, but from the moment when we feel the need to start it. You can always view the commit history if you couldn't find something in this document.
This is a major release with breaking changes focused on removing deprecated code and modernizing the codebase for Python 3.11+.
-
Minimum Python version is now 3.11
-
Removed deprecated functions:
context_partial- usefunctools.partialwithcontextvars.copy_context()new_event_loop- useasyncio.new_event_loop()directlycreate_default_event_loop- useasyncio.Runneror entrypointwrap_logging_handler- useThreadedHandlerdirectlyevent_loop_policy- removed, useloop_factoryparameter insteadset_current_loop/get_current_loopfromaiomisc.compat
-
Entrypoint changes:
- Parameter
policyreplaced withloop_factory: Callable[[], AbstractEventLoop] - Uses
asyncio.Runnerinternally (Python 3.11+) - New
default_loop_factory()function inaiomisc.compat
- Parameter
-
Thread pool code moved to
aiothreadspackage:IteratorWrapper,ChannelClosed,FromThreadChannelThreaded,threaded,ThreadedSeparate,threaded_separateThreadedIterable,threaded_iterable,threaded_iterable_separatewait_coroutine,sync_wait_coroutine,sync_await- These are still re-exported from
aiomiscfor backwards compatibility
_context_vars.pyrenamed tocontext_vars.py(now public module)- Added
aiothreads>=1.0.0as a dependency
In this release, the aiomisc_pytest module has been mostly removed, and has been separated into a separate package. This is the main, breaking change of this release.
- Dynamic running of services see also
- New
aiomisc.entrypoint.get_current()function returns current running entrypoint - Removed
aiomisc_pytestbecause is now a separate package aiomisc-pytest entrypointclass is final now.- Instance ordering not guaranteed in
Entrypoint.servicesmethod - The main function in
aiomisc_worker/forking.pyreturns 0 when keyboard interrupt received
- Migrate to poetry #154
- Use
poem-pluginsfor creatingaiomisc/version.pyfile and bump version when publishing. - some non-public imports might be broken, mainly typing, and the
aiomisc.iomodule - Buffered log handler in
aiomisc.log, is now correct finalize when an entrypoint stops. This is useful if the program uses multiple entrypoints while the program is running, and especially in tests. - Lots of changes in
aiomisc.iomodule:- Support stream compression for opening files with:
GZIP- compressed filesLZMA- compressed filesBZ2- compressed files
- Support stream compression for opening files with:
- Added
aiohttp_asgiobjects to__all__inaiomisc.service.asgi aiomisc.Servicesubclasses is now can be serialized withpickle- Improves typing for:
aiomisc.ioaiomisc.poolaiomisc.service.udpaiomisc.worker_pool.WorkerPool
- Use
- Improve documentation
- Remove code from
aiomisc_log.formatter.journaldand move it into the 3rd-party library logging-journald
threaded_iterableinternal implementation was reworked, it's a speed-up the functions whichyieldlots of items.threaded_iterable_separatedid not create a separate thread.
- Added
RecurringCallback - Rewritten
PeriodicCallbackandCronCallbackusingRecurringCallback
- Threaded iterable has been optimized and would not create too much asyncio.Task instances.
- Sentry handler for python3.10
WorkerPoolreworked and now spawning processes withos.forkon UNIX. This makes benefits on initializer has been passed. The allocated after initializer completion memory will be shared between processes with CoW.
- tcp and tls client services
- python<3.10 fixes
- retry connection attempts for client services
- rewrite rpc example with modern msgspec and client services
bind_portwill choose a free port when port passed as 0aiomisc_unused_port_factoryis now the fixture just detach but not close just created socket and port isn't free and not be used twice butbind_socketfunction will be able to bind it.- Fix
asyncbackofftype annotations
- Fix tests
- Fix
aiomisc.runin python 3.10 - Changed behavior in default event loop creation. In previous releases the
function
aiomisc.utils.create_default_event_loop()silently closes already created event loop. Now it checks is current event loop running, and raises anRuntimeErrorin this case.
- #126 reorder shutdown routines
- #128 session-scope agen fixture
- Added
RespawningProcessServiceservice class Serviceinstances are now serializable by pickle.PeriodicServicenow checks theintervalargument before starting.entrypointnot failing to stop when service instance implements.stop()method not properly.
- Tests for
JournaldLogHandlerandSDWatchdogServicehas been written loop.sock_sendallnow used forSDWatchdogService
- Added
aiomisc.service.RespawningProcessServicefor running python function in separate process and restart it when exiting. - Rewrite
aiomisc.WorkerPoolusingmultiprocessing.Processinstead ofsubprocess.Popen. aiomisc.ServiceMetais now inherited fromabc.ABCMeta. It means- fixed (cron): is now set current datetime as start point #120
aiomisc.ServiceMetais now inherited fromabc.ABCMeta. It means the decorations like@abc.abstractmethodwill work with service classes.- Added
aiomisc.service.ProcessServicefor running python function in separate process. - Change order of detection for
aiomisc_log.LogFormat.default()in case the stderr is not a tty. Fixesjournaldformatter auto detection. - Rewritten
aiomisc.iterator_wrapper.IteratorWrapperto avoid unnecessary context switches. Now,__in_threadmethod switches only when writing is possible instead of retrying every 100ms.
- Refactored
aiomisc.thread_pool.ThreadPoolExecutor
-
Split
aiomiscinto three python packages:aiomisc- still contains entrypoint, services, etc.aiomisc_log- logging related code.aiomisc_worket- worker-pools worker related code/
-
split plugins related code to
aiomisc.pluginsmodule from__init__.py -
port=0is a default foraiomisc.utils.bind_socket() -
aiomisc.run()function for running coroutine similar likeasuncio.runbut does all entrypoint work:- start services
- logging configuration
- creating thread-pool etc.
-
replace
time.monotonic()toloop.time()for:aiosmic.aggregatemoduleaiomisc.backoffmoduleaiomisc.cronmoduleaiomisc.poolmoduleaiomisc.process_poolmodule
It reduces system calls and slightly improves performance.
-
Used to modern syntax old python 3.5
# type:hints. -
Added
__slots__toaiomisc.counters.Metricandaiomisc.counters.Statistic -
Added entrypoint configuration from environment variables:
AIOMISC_LOG_LEVELAIOMISC_LOG_FORMATAIOMISC_LOG_CONFIGAIOMISC_LOG_FLUSHAIOMISC_LOG_BUFFERINGAIOMISC_LOG_BUFFERAIOMISC_POOL_SIZE
-
Added
aiomisc.entrypoint.POST_STARTandaiomisc.entrypoint.PRE_STOPsignals. -
Python 3.10 compatibility
-
Changed logging configuration behavior, now uncaught exceptions will be passed to root handler and log formatter which configured by
aiomisc.log.basic_config()function. Asyncio uncaught loop exceptions will have similar behavior. -
python -m aiomisc.pluginswill show available plugins. -
aiomisc.service.sdwatchdog.SDWatchdogService- The service allows you to run the application under systemd. The service automatically detects the systemd watchdog timer and sends notifications to it. -
Fixed
aiomisc.sercice.TLSServercompatibility for python 3.10 -
Used
asyncio.get_running_loopinstead of deprecated in 3.10asyncio.get_event_loop -
aiomisc.utils.run_in_executornow returnsAwaitable[Any]instead ofasuncio.Future. This is because there is no way to create aFutureoutside of the running event loop using onlyasyncio.get_running_loop. These changes return type for functions wrapped bythreaded. -
AIOMISC_NO_PLUGINSenvironment variable now disable loading any aiomisc plugin. -
Added new log formatters:
richandrich_tb- requires installedrichlibrary.rich_tbformats tracebacks usingrich.journald- write logs to journald.
-
aiomisc_log.formatter.journaldit's a logging handler for journald. -
Added
aiomisc.log.LogFormat.default()andaiomisc.log.LogLevel.default()methods.aiomisc.log.LogFormat.default()- detects the environment. In case the application running under systemd returnsjournald, whenrichhas been installed therichwill be returned, otherwisecolor. -
Removed
async_generatormodule support. Because python 3.5 is not supported anymore. -
Fixed "IO operation on closed file" error in pytest plugin.
-
Refactored
get_unused_portfunction andaiomisc_unused_port_factoryfixture -
Added
aiomisc_socket_factoryfixture which returns port number and socket object pair. -
Added tests for documentation examples through
pytest-rstmodule -
Added explanations for choosing module to perform Asynchronous files operations in the documentation.