Releases: kalaspuff/tomodachi
0.22.0
Improvements to previous behaviour for middlewares
- Handle exceptions lower in the stack for messaging services (AMQP and AWS SNS+SQS handlers), which now allows catching exceptions in middlewares, which was previously not possible. Note that existing middlewares calling underlying functions may differ in their behaviour unless logic catching raised exceptions with
try-finally
is applied. (github: @justcallmelarry)
Additional updates
- Improved documentation for uses of
tomodachi.get_service
(github: @jmfederico) - Type hint annotation improvements.
0.21.8
- Adds the possibility to add a function called
_stopping_service
to thetomodachi
Service class, which is run as soon as a termination signal is received by the service. (github: @justcallmelarry) - Fix for potential exceptions on botocore session client raising a
RuntimeError
, resulting in a tomodachi "Client has never been created in the first place" exception on reconnection to AWS APIs. - Added Python 3.10 to the CI test matrix run via GitHub Actions.
- Additional updates for compatibility with typing libraries to improve support for installations on Python 3.10.
- Supports
aiohttp
3.8.x versions. - Supports
tzlocal
3.x and 4.x releases.
0.21.7
0.21.6
- Now pins the
tzlocal
version to not use the 3.x releases as it would currently break services using scheduled functions (the@schedule
decorator, et al) iftzlocal
3.0 was installed. (issue: #1504) - Updated classifiers to identify that the library works on Python 3.10.
- Added the new
Framework :: aiohttp
classifier.
0.21.5
- If a
PYTHONPATH
environment value is set and a service is started without the--production
flag, the paths specified inPYTHONPATH
will be added to the list of directories to watch for code changes and in the event of any changes done to files on those directories, the service will restart. Previously only code changes in the directory or sub directory of the current working directory + the directory of the started service (or services) were monitored. - The
topic
argument to the@tomodachi.aws_sns_sqs
decorator is now optional, which is useful if subscribing to a SQS queue where the SNS topic or the topic subscriptions are set up apart from the service code, for example during deployment or as infra.
0.21.4
-
Encryption at rest for AWS SNS and/or AWS SQS which can optionally be configured by specifying the KMS key alias or KMS key id as a tomodachi service option
options.aws_sns_sqs.sns_kms_master_key_id
(to configure encryption at rest on the SNS topics for which the tomodachi service handles the SNS -> SQS subscriptions) and/oroptions.aws_sns_sqs.sqs_kms_master_key_id
(to configure encryption at rest for the SQS queues which the service is consuming).Note that an option value set to empty string (
""
) orFalse
will unset the KMS master key id and thus disable encryption at rest. (The AWS APIs for SNS and SQS uses empty string value to the KMSMasterKeyId attribute to disable encryption with KMS if it was previously enabled).If instead an option is completely unset or set to
None
value no changes will be done to the KMS related attributes on an existing topic or queue.If it's expected that the services themselves, via their IAM credentials or assumed role, are responsible for creating queues and topics, these options could be used to provide encryption at rest without additional manual intervention
However, do not use these options if you instead are using IaC tooling to handle the topics, queues and subscriptions or that they for example are created / updated as a part of deployments. To not have the service update any attributes keep the options unset or set to a
None
value.AWS Documentation:
-
Fixes an issue where a GET request to an endpoint serving static files via
@http_static
could be crafted to probe the directory structure setup (but not read file content outside of its permitted path), by applying directory traversal techniques. This could expose the internal directory structure of the file system in the container or environment that the service is hosted on. Limited to if@http_static
handlers were used within the service and those endpoints could be accessed. -
Additional validation for the path used in the
@http_static
decorator to prevent a developer from accidentally supplying a"/"
or""
value to thepath
argument, which in those cases could lead to unintended files being exposed via the static file handler.
0.21.3
- Fixes an issue causing a
UnboundLocalError
if an incoming message to a service that had specified the enveloping implementationJsonBase
where JSON encoded but actually wasn't originating from a source using aJsonBase
compatible envelope. - Fixes error message strings for some cases of AWS SNS + SQS related cases of
botocore.exceptions.ClientError
. - Fixes the issue where some definitions of filter policies would result in an error when running mypy – uses
Sequence
instead ofList
in type hint definition for filter policy input types. - Internal updates for developer experience – refactoring and improvements for future code analysis and better support for IntelliSense.
- Updates to install typeshed generated type hint annotation stubs and updates to support
mypy==0.910
.
0.21.2
- Bugfix for an issue which caused the
sqs.DeleteMessage
API call to be called three times for each processed SQS message (the request to delete a message from the queue is idempotent) when using AWS SNS+SQS via@tomodachi.aws_sns_sqs
. - Now properly cleaning up clients created with
tomodachi.helpers.aiobotocore_connector
foraiobotocore
, which previously could result in the error output "Unclosed client session" if the service would fail to start, for example due to initialization errors.
0.21.1
- Added
sentry_sdk
to the list of modules and packages to not be unloaded fromsys.modules
during hot reload of the running when code changes has been noticed. This to prevent errors likeTypeError: run() takes 1 positional argument but X were given
fromsentry_sdk.integrations.threading
when handling early errors or leftover errors from previous session.
0.21.0
- Uses the socket option
SO_REUSEPORT
by default on Linux unless specifically disabled via thehttp.reuse_port
option set toFalse
. This will allow several processes to bind to the same port, which could be useful when running services via a process manager such assupervisord
or when it's desired to run several processes of a service to utilize additional CPU cores. Thehttp.reuse_port
option doesn't have any effect when a service is running on a non-Linux platform. (github: @tranvietanh1991) - Services which works as AMQP consumers now has a default prefetch count value of 100, where previously the service didn't specify any prefetch count option, which could exhaust the host's resources if messages would be published faster to the queue than the services could process them. (github: @tranvietanh1991)
- AWS SNS+SQS calls now uses a slightly changed config which will increase the connection pool to 50 connections, decreases the connect timeout to 8 seconds and the read timeout to 35 seconds.
- Possible to run services using without using the
tomodachi
CLI, by addingtomodachi.run()
to the end of the Python file invoked bypython
which will start services within that file. Usually in aif __name__ == "__main__":
if-block. - The environment variable
TOMODACHI_LOOP
can be used to specify the event loop implementation in a similar way as the CLI argument--loop [auto|asyncio|uvloop]
would. - Environment variable
TOMODACHI_PRODUCTION
set to1
can be used to run the service without the file watcher for automatic code reloads enabled, which then yields higher performance. Equivalent as starting the service with the--production
argument. - Smaller performance improvements throughout the framework.
- Improved error handling overall in regards to non-standard exceptions and additional output, if scheduled tasks are unable to run due to other start methods not completing their initial setup.