Skip to content

Commit 6e53e81

Browse files
Show permission troubleshooting URL in asyncio.tools
Print a URL with steps to resolve permission errors when inspecting processes using asyncio.tools.
1 parent 5e21f89 commit 6e53e81

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Lib/asyncio/tools.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,20 @@ def _print_cycle_exception(exception: CycleFoundException):
194194
print(f"cycle: {inames}", file=sys.stderr)
195195

196196

197+
def exit_with_permission_help_text():
198+
"""
199+
Prints a message pointing to platform-specific permission help text and exits the program.
200+
This function is called when a PermissionError is encountered while trying
201+
to attach to a process.
202+
"""
203+
print(
204+
"Error: The specified process cannot be attached to due to insufficient permissions.\n"
205+
"See the Python documentation for details on required privileges and troubleshooting:\n"
206+
"https://docs.python.org/3.14/howto/remote_debugging.html#permission-requirements\n"
207+
)
208+
sys.exit(1)
209+
210+
197211
def _get_awaited_by_tasks(pid: int) -> list:
198212
try:
199213
return get_all_awaited_by(pid)
@@ -202,6 +216,8 @@ def _get_awaited_by_tasks(pid: int) -> list:
202216
e = e.__context__
203217
print(f"Error retrieving tasks: {e}")
204218
sys.exit(1)
219+
except PermissionError as e:
220+
exit_with_permission_help_text()
205221

206222

207223
def display_awaited_by_tasks_table(pid: int) -> None:

0 commit comments

Comments
 (0)