gh-116750: Add clear_tool_id function to unregister events and callbacks (#124568)

This commit is contained in:
Tian Gao 2024-10-01 10:32:55 -07:00 committed by GitHub
parent b482538523
commit 5e0abb4788
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 165 additions and 8 deletions

View file

@ -50,16 +50,14 @@ Registering and using tools
*tool_id* must be in the range 0 to 5 inclusive.
Raises a :exc:`ValueError` if *tool_id* is in use.
.. function:: clear_tool_id(tool_id: int, /) -> None
Unregister all events and callback functions associated with *tool_id*.
.. function:: free_tool_id(tool_id: int, /) -> None
Should be called once a tool no longer requires *tool_id*.
.. note::
:func:`free_tool_id` will not disable global or local events associated
with *tool_id*, nor will it unregister any callback functions. This
function is only intended to be used to notify the VM that the
particular *tool_id* is no longer in use.
Will call :func:`clear_tool_id` before releasing *tool_id*.
.. function:: get_tool(tool_id: int, /) -> str | None