Release history¶
stackscope 0.2.2 (2024-02-27)¶
Bugfixes¶
stackscope 0.2.1 (2024-02-02)¶
Bugfixes¶
Fixed inspection of async context managers that contain a
CLEANUP_THROW
bytecode instruction in their__aenter__
sequence. This can appear on 3.12+ if you write an async context manager inside anexcept
orfinally
block, and would previously produce an inspection warning. (#11)The first invocation of
stackscope.extract()
no longer leaves a partially-exhausted async generator object to be garbage collected, which previously could confuse async generator finalization hooks. (#12)
stackscope 0.2.0 (2023-12-22)¶
With this release, stackscope can print full Trio task trees out-of-the-box.
Try print(stackscope.extract(trio.lowlevel.current_root_task(),
recurse_child_tasks=True))
.
Backwards-incompatible changes¶
The
unwrap_context()
hook now accepts an additionalContext
argument. This saves on duplicated effort betweenelaborate_context()
andunwrap_context()
, avoiding exponential time complexity in some pathological cases.Removed support for Python 3.7.
User-facing improvements to core logic¶
Added support for representing child tasks in structured concurrency libraries, by allowing
Context.children
to containStack
s in addition to the existing support for childContext
s. By default, the child tasks will not have their frames filled out, but you can override this with the new recurse_child_tasks parameter toextract()
. (#9)Added
Frame.hide_line
andContext.hide
attributes for more precise control of output.Added a new attribute
Stack.root
which preserves the original “stack item” object that was passed toextract()
. For stacks generated from async child tasks, this will be theTask
object.Added support for Python 3.12.
Library support (“glue”) improvements¶
stackscope can now trace seamlessly across Trio/thread boundaries when extracting a stack that includes calls to
trio.to_thread.run_sync()
and/ortrio.from_thread.run()
. The functions running in the cross-thread child will appear in the same way that they would if they had been called directly without a thread transition. (#8)Added glue to support
pytest-trio
. (#4)Updated Trio glue to support unwrapping
trio.lowlevel.Task
s and filling in the child tasks of atrio.Nursery
.
Improvements for glue developers¶
A library can now ship its own stackscope customizations without requiring that all of its users install stackscope. Any module may define a function called
_stackscope_install_glue_()
, which stackscope will call when it is first used to extract a stack trace after the module has been imported. (#7)Added
unwrap_context_generator()
hook for more specific customization of generator-based context managers.Modified the
elaborate_frame()
hook to be able to return a sequence of stack items rather than just a single one. This permits more expressive augmentation rules, such as inserting elements into the stack trace without removing what would’ve been there if the hook were not present.Added a new function
extract_child()
for use in customization hooks. It is likeextract()
except that it reuses the options that were specified for the outerextract()
call, and contains some additional logic to prune child task frames if the outerextract()
didn’t ask for them.elaborate_frame()
now runs afterFrame.contexts
is populated, so it has the chance to modify the detected context managers.
stackscope 0.1.0 (2023-04-12)¶
Initial release.