<!-- Source: https://docs.squirro.com/en/latest/api/squirro_client.topic.ScanContext.html -->
# ScanContext

**`class ScanContext(generator, cleanup_func)`**

Bases: [`AbstractContextManager`](https://docs.python.org/3.11/library/contextlib.html#contextlib.AbstractContextManager)[[`Iterator`](https://docs.python.org/3.11/library/collections.abc.html#collections.abc.Iterator)[`T`]], [`Generator`](https://docs.python.org/3.11/library/collections.abc.html#collections.abc.Generator)[`T`, [`None`](https://docs.python.org/3.11/library/constants.html#None), [`None`](https://docs.python.org/3.11/library/constants.html#None)], [`Generic`](https://docs.python.org/3.11/library/typing.html#typing.Generic)[`T`]

Context manager wrapper for scan operations that ensures proper cleanup.

Implements two use cases:

- **Recommended**: ContextManager over Iterator[T] for use with ‘with’ statements
- **Legacy**: Generator[T] for direct iteration (issues deprecation warning)

When used without entering the context manager, a deprecation warning is issued.

> **Note**
>
> This is a generic class parameterized by type T, which represents
> the type of items yielded by the generator.

Methods SummaryMethods Documentation

**`close()`**

Close the generator and perform cleanup.

Return type

[`None`](https://docs.python.org/3.11/library/constants.html#None)

**`send(value)`**

Send a value to the generator (required by Generator protocol).

Return type

[`TypeVar`](https://docs.python.org/3.11/library/typing.html#typing.TypeVar)(`T`)

**`throw(typ, val=None, tb=None)`**

Throw an exception into the generator (required by Generator protocol).

Return type

[`TypeVar`](https://docs.python.org/3.11/library/typing.html#typing.TypeVar)(`T`)
