Skip to content

Prefix cache functions that are non threadsafe with async_#724

Merged
bdraco merged 14 commits into
python-zeroconf:masterfrom
bdraco:cache_struct
Jun 18, 2021
Merged

Prefix cache functions that are non threadsafe with async_#724
bdraco merged 14 commits into
python-zeroconf:masterfrom
bdraco:cache_struct

Conversation

@bdraco
Copy link
Copy Markdown
Member

@bdraco bdraco commented Jun 18, 2021

Adding (zc.cache.add -> zc.cache.async_add_records), removing (zc.cache.remove -> zc.cache.async_remove_records), and expiring the cache (zc.cache.expire -> zc.cache.async_expire) the cache is not threadsafe and must be called from the event loop (previously the Engine select loop before 0.32)

  • These functions should only be run from the event loop as they are NOT thread safe.

  • We never expect these functions will be called externally, however it was possible so this is documented as a breaking change. It is highly recommended that external callers do not modify the cache directly.

@bdraco
Copy link
Copy Markdown
Member Author

bdraco commented Jun 18, 2021

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 18, 2021

Codecov Report

Merging #724 (9ca263e) into master (88aa610) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #724      +/-   ##
==========================================
+ Coverage   97.87%   97.92%   +0.04%     
==========================================
  Files          18       18              
  Lines        2168     2168              
  Branches      377      377              
==========================================
+ Hits         2122     2123       +1     
  Misses         29       29              
+ Partials       17       16       -1     
Impacted Files Coverage Δ
zeroconf/_cache.py 100.00% <100.00%> (ø)
zeroconf/_core.py 97.86% <100.00%> (ø)
zeroconf/_handlers.py 100.00% <100.00%> (ø)
zeroconf/_utils/aio.py 100.00% <0.00%> (+3.57%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 88aa610...9ca263e. Read the comment docs.

@bdraco
Copy link
Copy Markdown
Member Author

bdraco commented Jun 18, 2021

Can't do this yet because there is a bug in get_all_by_details
#728

There is currently a bug in the implementation where an entry
can exist in two places in the cache with different TTLs. Since
a known answer cannot be both expired and expired at the same
time, this is a bug that needs to be fixed.

@bdraco bdraco merged commit 3503e76 into python-zeroconf:master Jun 18, 2021
@bdraco bdraco deleted the cache_struct branch June 18, 2021 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants