Skip to content

Examples: Standardize resource cleanup #1676

@rparolin

Description

@rparolin

Parent issue: #1673

Goal

Decide on and apply a consistent resource cleanup policy across all examples.

Current state

  • Most examples do NOT close streams or buffers explicitly.
  • Only saxpy.py and memory_ops.py demonstrate explicit close() calls.
  • strided_memory_view_gpu.py uses a finally block for cleanup, others don't.
  • No examples use context managers for resource management.

Decisions needed

  1. Should examples demonstrate explicit close() calls as best practice?
  2. Should examples use context managers (if the API supports them)?
  3. Should examples use try/finally blocks for cleanup?
  4. Is it acceptable for simple examples to rely on process exit for cleanup?

Files affected

All 25 example files listed in #1673.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cuda.coreEverything related to the cuda.core moduletriageNeeds the team's attention

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions