caronc / apprise

Apprise - Push Notifications that work with just about every platform!
https://hub.docker.com/r/caronc/apprise
BSD 2-Clause "Simplified" License
10.91k stars 384 forks source link

Improved async/threading attachment support #1086

Closed caronc closed 3 months ago

caronc commented 3 months ago

Description:

Related issue (if applicable): BirdNET-Pi/1171

Issue was detected in another system. Situation is a racing condition where multiple services want to share the same retrieved attachment. The problem is the asynchronous process starts all fetching at the same time. The ideal approach is to fetch the image once, and the remaining services share from the single fetch.

This PR Resolves this issue.

Checklist

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in as follows:
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch
pip install git+https://github.com/caronc/apprise.git@/improved-attachment-support

# Test out the changes by just sending a web based attachment to 2 or more endpoints:
apprise -t "Test Title" -b "Test Message" \
  discord://credentials \
  pover://credentials \
 --attach=http://website/remote/image.jpg
codecov-commenter commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.28%. Comparing base (195d0ef) to head (e9f6ad3).

:exclamation: Current head e9f6ad3 differs from pull request most recent head f14e764. Consider uploading reports for the commit f14e764 to get more accurate results

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1086 +/- ## ======================================= Coverage 99.28% 99.28% ======================================= Files 137 137 Lines 17874 17885 +11 Branches 3649 3652 +3 ======================================= + Hits 17746 17757 +11 Misses 119 119 Partials 9 9 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.