Skip to content

Add async support to TrackQuery decorator#37

Merged
MuddyHope merged 7 commits into
MuddyHope:mainfrom
yog-32:async-tracking-feature
Jun 22, 2025
Merged

Add async support to TrackQuery decorator#37
MuddyHope merged 7 commits into
MuddyHope:mainfrom
yog-32:async-tracking-feature

Conversation

@yog-32

@yog-32 yog-32 commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds support for tracking async functions using the TrackQuery decorator.

Why is this needed?

Many modern frameworks (FastAPI, asyncpg, etc.) use async DB operations.

What was changed?

  • Modified core.py to detect async functions and await them accordingly
  • Added new unit test for async decorator behavior

Related Issue:

Fixes #31

@MuddyHope

Copy link
Copy Markdown
Owner

Hi @yog-32, Can you fix your PR? None of the tests are passing. Also add a few examples for the functionality you are adding.

@yog-32

yog-32 commented Jun 17, 2025

Copy link
Copy Markdown
Contributor Author

I have done necessary changes. Looking forward to your feedback! 😊

@MuddyHope MuddyHope left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I'll test it once you have taken care of these changes.

Comment thread tests/test_config.py
record = caplog.records[0]
assert record.levelname == "ERROR"
assert "MyClass" in record.message
assert "do_slow_work" in record.message

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why were these removed?

Comment thread pyquerytracker/core.py Outdated

# Set up logger
logger = logging.getLogger("pyquerytracker")
logger.setLevel(logging.DEBUG)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please remove this.

Comment thread tests/test_core.py

MyClass().do_work(2, 3)
assert len(caplog.records) == 1
record = caplog.records[0]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Don't modify the pre-existing test cases for them to pass.

@yog-32

yog-32 commented Jun 18, 2025

Copy link
Copy Markdown
Contributor Author

Hello,

I think the CI build is currently failing on the new async tests. This appears to be due to the "pytest-asyncio" dependency not being installed in the CI environment. The tests are running fine on my local machine, so the failures likely stem from missing dependencies during CI runs.

To resolve this, I’ve updated pyproject.toml to include all development dependencies under an optional [test] extras group, following modern Python packaging standards. To install the necessary test dependencies, please run:

python -m pip install ".[test]"

Let me know if the tests still fail after installing the extras—I’ll be happy to investigate further if needed.

@yog-32

yog-32 commented Jun 19, 2025

Copy link
Copy Markdown
Contributor Author

Hey @MuddyHope!, have you tried installing pytest-asyncio? The tests need it, and my code’s good to go once that’s in place!

{155AC13A-7E1C-4C37-99E2-CFB78F7E9959}

@MuddyHope

Copy link
Copy Markdown
Owner

Can you resolve these conflicts, @yog-32. I'll test out these before merging.

@MuddyHope

Copy link
Copy Markdown
Owner

Can you pull latest main @yog-32, and resolve the conflicts?

@MuddyHope MuddyHope merged commit b053276 into MuddyHope:main Jun 22, 2025
1 of 4 checks passed
@MuddyHope

Copy link
Copy Markdown
Owner

Thanks @yog-32, it's merged.

@yog-32 yog-32 deleted the async-tracking-feature branch June 23, 2025 10:49
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.

Add support for async query tracking (#Async/Await Decorator)

2 participants