Prerequisites and connection details for attaching to a live Python process with PyFlightProfiler. Read this skill first before using any other PyFlightProfiler command (watch, trace, stack, perf, etc.).
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Inspect live Python class instances in a running process — find all instances of a class, examine their attributes/state, or invoke methods on them. Also supports forcing GC. Use this when you need to probe object-level runtime state beyond what watch/getglobal can provide.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
설치 방법 보기설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.
Inspect live Python class instances at runtime. The primary use case is state inspection — find all instances of a given class and examine their current attributes — and method invocation — call methods on found instances via -e expressions. Also supports forcing a garbage collection cycle.
Prerequisites: Read the flight-profiler-attach skill first for platform requirements, installation, permissions, and connection details.
instances[0].get_stats(), instances[0].dump_state())status == "error")flight_profiler <pid> --cmd "vmtool -a <action> [options]" --no-color
| Flag | Description | Default |
|---|---|---|
-a, --action | Action: forceGc or getInstances | required |
-c, --class | Class locator: module class | required for getInstances |
-e, --expr <value> | Expression to evaluate on found instances. Variable is instances (a list). | instances |
-x, --expand <value> | Object tree expand level (1-6) | 1 |
-n, --limit <value> | Max instances to collect (-1 for unlimited) | 10 |
-r, --raw | Use __str__ (equivalent to print(obj)) instead of default JSON serialization | off |
-v, --verbose | Display all nested items in list/dict without truncation | off |
-e Expression-e directly controls what you see in the output. Always match the user's intent to the right expression — the default instances dumps all found objects.
| User intent | -e value |
|---|---|
| See all instances | instances (default) |
| Count how many instances exist | len(instances) |
| Inspect a single instance in detail | instances[0] (combine with -x 2) |
| Filter instances by attribute | [i for i in instances if i.attr=='val'] |
| Extract one field from all instances | [i.field for i in instances] |
| Check if any instance matches a condition | any(i.status=='error' for i in instances) |
| Invoke a diagnostic method on an instance | instances[0].get_stats() |
| Invoke a method on all instances | [i.get_status() for i in instances] |
Returns a plain text message:
Gc execute successfully, totally 76 unreachable objects are freed.
Returns an expression result block (same format as getglobal/watch):
EXPR: instances
TYPE: <class 'list'>
VALUE: [
Connection({'host': 'queue', 'port': 5672, 'status': 'error'}),
Connection({'host': 'cache', 'port': 6379, 'status': 'idle'}),
Connection({'host': 'db-replica', 'port': 5433, 'status': 'active'}),
Connection({'host': 'db-primary', 'port': 5432, 'status': 'active'})
]
| Field | Description |
|---|---|
EXPR | The expression used (default instances) |
TYPE | Python type of the expression result |
VALUE | The value, formatted as JSON (or __str__ if -r) |
flight_profiler <pid> --cmd "vmtool -a forceGc" --no-color
Gc execute successfully, totally 76 unreachable objects are freed.
flight_profiler <pid> --cmd "vmtool -a getInstances -c __main__ Connection" --no-color
EXPR: instances
TYPE: <class 'list'>
VALUE: [
Connection({'host': 'queue', 'port': 5672, 'status': 'error'}),
Connection({'host': 'cache', 'port': 6379, 'status': 'idle'}),
Connection({'host': 'db-replica', 'port': 5433, 'status': 'active'}),
Connection({'host': 'db-primary', 'port': 5432, 'status': 'active'})
]
flight_profiler <pid> --cmd "vmtool -a getInstances -c __main__ Connection -e len(instances)" --no-color
EXPR: len(instances)
TYPE: <class 'int'>
VALUE: 4
Use -e instances[0] to pick one instance and -x 2 to expand its attributes:
flight_profiler <pid> --cmd "vmtool -a getInstances -c __main__ Connection -e instances[0] -x 2" --no-color
EXPR: instances[0]
TYPE: <class '__main__.Connection'>
VALUE: Connection({
"host": "queue",
"port": 5672,
"status": "error"
})
Find only instances with status == "error". Note: list comprehension expressions with quotes need careful shell escaping:
flight_profiler <pid> --cmd 'vmtool -a getInstances -c __main__ Connection -e "[i for i in instances if i.status==\"error\"]"' --no-color
EXPR: [i for i in instances if i.status=="error"]
TYPE: <class 'list'>
VALUE: [
Connection({'host': 'queue', 'port': 5672, 'status': 'error'})
]
-r (use __str__ instead of JSON)flight_profiler <pid> --cmd "vmtool -a getInstances -c __main__ Connection -r" --no-color
EXPR: instances
TYPE: <class 'list'>
VALUE: [<__main__.Connection object at 0x1056debb0>, <__main__.Connection object at 0x1056dec10>, ...]
Shows Python's default __str__ representation for each object.
-n-n 2 collects at most 2 instances:
flight_profiler <pid> --cmd "vmtool -a getInstances -c __main__ Connection -n 2" --no-color
EXPR: instances
TYPE: <class 'list'>
VALUE: [
Connection({'host': 'queue', 'port': 5672, 'status': 'error'}),
Connection({'host': 'cache', 'port': 6379, 'status': 'idle'})
]
flight_profiler <pid> --cmd "vmtool -a getInstances -c __main__ Task -e instances[0] -x 2" --no-color
EXPR: instances[0]
TYPE: <class '__main__.Task'>
VALUE: Task({
"name": "cleanup_logs",
"priority": 1,
"task_id": 3
})
-e Expression GuideThe -e option accepts any valid Python expression. The variable instances is a list containing the found class instances.
Common patterns:
# Default: show all instances
-e instances
# Count instances
-e len(instances)
# Pick a specific instance
-e instances[0]
# Filter by attribute
-e "[i for i in instances if i.status=='error']"
# Get a specific attribute from all instances
-e "[i.host for i in instances]"
# Check if any instance matches a condition
-e "any(i.status=='error' for i in instances)"
# Aggregate values
-e "sum(i.priority for i in instances)"
# Invoke a method on an instance
-e instances[0].get_stats()
-e instances[0].health_check()
# Invoke a method on all instances
-e "[i.get_status() for i in instances]"
Note: When using list comprehensions or expressions with quotes in shell, use single quotes for the outer --cmd and escaped double quotes inside the expression (see example 5).
Note: -e expressions execute inside the target process. Invoking methods on instances will actually run them — use this for read-only diagnostic methods (e.g., get_stats(), dump_state()). Avoid calling methods with side effects unless you intend to.
flight_profiler <pid> --cmd "vmtool -a getInstances -c __main__ Connection -n -1 -v" --no-color > /tmp/vmtool_output.txt
-e len(instances), or a few instances), display the full result directly to the user so they can see it immediately.When an object is too large to serialize or the output is truncated/incomplete:
Prefer minimal extraction — use -e to extract only the fields you need, instead of the entire instance:
# Instead of serializing the entire instance:
-e instances[0]
# Extract only the field you care about:
-e instances[0].status
-e [i.host for i in instances]
-e type(instances[0]),len(vars(instances[0]))
Use -v (verbose) — if you do need the full object, add -v to disable truncation so all nested items in lists/dicts are shown completely.
-e expressions to filter and analyze instances without dumping everythinginstances variable in -e is a list — you can use any Python list operation on it-n to limit collection when you only need a sample — collecting all instances of a very common class can be slowgc.get_referrers() — it may not match creation orderflight_profiler/plugins/vmtool/cli_plugin_vmtool.pyflight_profiler/plugins/vmtool/vmtool_parser.pyflight_profiler/plugins/vmtool/server_plugin_vmtool.py아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.
로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.
아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.
Prerequisites and connection details for attaching to a live Python process with PyFlightProfiler. Read this skill first before using any other PyFlightProfiler command (watch, trace, stack, perf, etc.).
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Inspect Python module global field or class static field value in a running Python process. Use this for safe, read-only inspection of global variables, configuration objects, or class-level state.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Translate a file path to its Python module name in a running Python process. Use this when you know a file path but need the module name for commands like watch, trace, or reload.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Hot-reload a Python function implementation from the latest file content without restarting the process. Use this to apply code fixes live after identifying a bug with watch/trace.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Inspect stack frames of a running Python process including thread stacks, native C-level frames, and async coroutine stacks. Use this to see what each thread is currently doing and diagnose hangs, deadlocks, or stuck async tasks.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.
Trace execution time of Python method invocations in a live process with call stack visualization. Use this to see a hierarchical call tree showing which sub-calls are slow and where time is spent within a function.
한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.