Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use aiojobs for background tasks #573

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

citramon
Copy link
Contributor

What do these changes do?

Preparing for new release.
Use aiojobs for background tasks.

Are there changes in behavior for the user?

nope

Related issue number

Resolvers: 536

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> (e.g. 588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the PR
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: Fix issue with non-ascii contents in doctest text files.

@codecov
Copy link

codecov bot commented May 18, 2022

Codecov Report

Merging #573 (46a197c) into master (760ccab) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #573   +/-   ##
=======================================
  Coverage   98.17%   98.17%           
=======================================
  Files          13       13           
  Lines        1040     1043    +3     
  Branches      140      140           
=======================================
+ Hits         1021     1024    +3     
  Misses         15       15           
  Partials        4        4           
Flag Coverage Δ
unit 98.17% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
aiocache/decorators.py 100.00% <100.00%> (ø)

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 760ccab...46a197c. Read the comment docs.

@citramon
Copy link
Contributor Author

@Dreamsorcerer, this PR for preparing to new release from this TODO list.
Could you check it?

Comment on lines +14 to +15
loop = asyncio.get_event_loop()
scheduler = loop.run_until_complete(aiojobs.create_scheduler(pending_limit=0, limit=None))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work correctly. When the user runs their application, it'll be on a different loop.

You'll need to instantiate it inside the class, probably in the __init__() method.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, if this is in the decorator, that may have the same problem. We may need to think on this a little further, maybe we can create it in decorator() if it doesn't already exist...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also highlights another issue to me, the scheduler and cache should both have .close() called at the end of the application. But, I don't see any way for a decorator to do that.

I'm starting to think that the decorators should have the Cache instance passed to them or something, so the developer can handle the lifetime of the caches properly.

Turns out this is more complex than I thought...

@@ -38,6 +38,7 @@
'redis:python_version>="3.8"': ["aioredis>=1.3.0,<2.0"],
"memcached": ["aiomcache>=0.5.2"],
"msgpack": ["msgpack>=0.5.5"],
"aiojobs": ["aiojobs>=1.0.0"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't an extra, it's required, so needs to be added to install_requires.

@Dreamsorcerer Dreamsorcerer added this to the 1.0 milestone Jan 2, 2023
@Dreamsorcerer
Copy link
Member

Depends on #609.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants