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

Add support for infinite depth tracing and fix pytest warning #235

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

elijahqi
Copy link

Description:

This pull request introduces two improvements to the codebase:

  1. Infinite depth support: Added support for infinite depth function call tracing by allowing the depth parameter to be set to float('inf'). This enables tracing of recursive functions without a predefined depth limit. A new test case, test_infinite_depth_support.py, has been added to verify the correct behavior of this feature.
  2. Fix pytest warning: Modified the current_thread.getName() call to current_thread.name to avoid pytest warnings. Updated the thread_info variable assignment accordingly:
thread_info = "{ident}-{name} ".format(
    ident=current_thread.ident, name=current_thread.name)

  1. Optimization for large depth values: Updated the frame tracing code to prevent tracing of imported libraries when a large depth value is provided. This helps avoid unnecessary tracing and improves performance.

Please review the changes and let me know if you have any questions or suggestions.

Elijah Qi and others added 6 commits April 15, 2023 22:11
Body:
This commit resolves a DeprecationWarning in the tracer.py file. The deprecated getName() method, which is used to get the name of the current_thread object, has been replaced with the recommended name attribute.

Changes:
- Updated line 473 in tracer.py to use current_thread.name instead of current_thread.getName()

With this change, the deprecation warning will no longer appear when running tests, and the code will be compatible with future releases of Python that may remove the deprecated method.
This commit adds a new feature that enables infinite depth support for function call tracing in pysnooper. The test_infinite_depth_support test case has been added to verify the correct behavior of the feature. The test case covers the case of tracing a recursive function call with unlimited depth and checks the output against the expected values. The feature works by setting the depth parameter to float('inf') in the pysnooper.snoop function.
@cool-RR
Copy link
Owner

cool-RR commented Apr 20, 2023

Thank you, but please separate the 3 issues into 3 separate PRs. You could either do them in parallel, or wait to finish with one before continuing the other, whichever is more convenient for you. Then I'll review.

@elijahqi
Copy link
Author

Ok, Thanks, will do that!

@@ -1,4 +1,5 @@
# Copyright 2019 Ram Rachum and collaborators.
# -*- coding: utf-8 -*-
# Copyright 2023 Elijah Qi and Liuqing Yang.

This comment was marked as resolved.

@@ -1,4 +1,5 @@
# Copyright 2019 Ram Rachum and collaborators.
# -*- coding: utf-8 -*-
# Copyright 2023 Elijah Qi and Liuqing Yang.
# This program is distributed under the MIT license.

import io

This comment was marked as off-topic.

Copy link

@Lo236816 Lo236816 left a comment

Choose a reason for hiding this comment

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

undo changes< Duplicate of #

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

4 participants