class ModuleInspect: (source)
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 |
Return some properties of a module/package using runtime introspection.
Raise InspectError if the target couldn't be imported.
| Parameters | |
package_id:str | Undocumented |
| Returns | |
ModuleProperties | Undocumented |
Get value from the queue.
Return the value read from the queue, or None if the process unexpectedly died.
| Returns | |
Union[ | Undocumented |