Skip to content

Conversation

@pablogsal
Copy link
Member

Users reported confusion when using memray attach with the --duration flag
because the command would exit immediately without any indication that
tracking had started successfully or was still running. This made it
difficult to know if the attach operation worked, and if interrupted,
there was no clear feedback about what would happen to the background
tracking.

Additionally, users would waste time going through the entire attach
process only to discover at the end that their output file already existed,
requiring them to restart with the --force flag.

This change addresses these issues by checking the output file existence
upfront before any injection work begins, and by showing detailed progress
through each phase of the attach and detach operations. Users can now see
exactly which step is in progress, making it easier to diagnose slow or
stuck operations.

For users who want the command to wait until tracking completes, a new
--wait flag is provided that displays a live progress bar showing time
elapsed and remaining. This makes the behavior more predictable while
maintaining backward compatibility for users who expect the command to
return immediately.

Fixes #831
Fixes #701

Issue number of the reported bug or feature request: #

Describe your changes
A clear and concise description of the changes you have made.

Testing performed
Describe the testing you have performed to ensure that the bug has been addressed, or that the new feature works as planned.

Additional context
Add any other context about your contribution here.

@codecov-commenter
Copy link

codecov-commenter commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 18.18182% with 81 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.83%. Comparing base (95fcf68) to head (fbd83af).

Files with missing lines Patch % Lines
src/memray/commands/attach.py 18.18% 81 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #841      +/-   ##
==========================================
- Coverage   92.44%   91.83%   -0.61%     
==========================================
  Files          99       99              
  Lines       11682    11768      +86     
  Branches      426      432       +6     
==========================================
+ Hits        10799    10807       +8     
- Misses        883      961      +78     
Flag Coverage Δ
cpp 91.83% <18.18%> (-0.61%) ⬇️
python_and_cython 91.83% <18.18%> (-0.61%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Users reported confusion when using memray attach with the --duration flag
because the command would exit immediately without any indication that
tracking had started successfully or was still running. This made it
difficult to know if the attach operation worked, and if interrupted,
there was no clear feedback about what would happen to the background
tracking.

Additionally, users would waste time going through the entire attach
process only to discover at the end that their output file already existed,
requiring them to restart with the --force flag.

This change addresses these issues by checking the output file existence
upfront before any injection work begins, and by showing detailed progress
through each phase of the attach and detach operations. Users can now see
exactly which step is in progress, making it easier to diagnose slow or
stuck operations.

For users who want the command to wait until tracking completes, a new
--wait flag is provided that displays a live progress bar showing time
elapsed and remaining. This makes the behavior more predictable while
maintaining backward compatibility for users who expect the command to
return immediately.

Fixes bloomberg#831
Fixes bloomberg#701

Signed-off-by: Pablo Galindo <[email protected]>
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.

memray attach with --duration exits immediately instead of tracking for the given time attach ignores --duration

2 participants