class documentation

class ModuleInspect: (source)

View In Hierarchy

Perform runtime introspection of modules in a separate process.

Reuse the process for multiple modules for efficiency. However, if there is an error, retry using a fresh process to avoid cross-contamination of state between modules.

We use a separate process to isolate us from many side effects. For example, the import of a module may kill the current process, and we want to recover from that.

Always use in a with statement for proper clean-up:

with ModuleInspect() as m:
p = m.get_package_properties('urllib.parse')
Method __enter__ Undocumented
Method __exit__ Undocumented
Method __init__ Undocumented
Method close Free any resources used.
Method get​_package​_properties Return some properties of a module/package using runtime introspection.
Instance Variable counter Undocumented
Instance Variable proc Undocumented
Instance Variable results Undocumented
Instance Variable tasks Undocumented
Method _get​_from​_queue Get value from the queue.
Method _start Undocumented
def __enter__(self): (source)

Undocumented

Returns
ModuleInspectUndocumented
def __exit__(self, *args): (source)

Undocumented

Parameters
*args:objectUndocumented
def __init__(self): (source)

Undocumented

def close(self): (source)
Free any resources used.
def get_package_properties(self, package_id): (source)

Return some properties of a module/package using runtime introspection.

Raise InspectError if the target couldn't be imported.

Parameters
package​_id:strUndocumented
Returns
ModulePropertiesUndocumented
counter: int = (source)

Undocumented

proc = (source)

Undocumented

results: Queue[Union[ModuleProperties, str]] = (source)

Undocumented

tasks: Queue[str] = (source)

Undocumented

def _get_from_queue(self): (source)

Get value from the queue.

Return the value read from the queue, or None if the process unexpectedly died.

Returns
Union[ModuleProperties, str, None]Undocumented
def _start(self): (source)

Undocumented