File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -77,8 +77,9 @@ def deactivate(session: Optional[int] = None) -> None:
77
77
deactivated_hooks = set ()
78
78
for session in sessions :
79
79
for hook in HookManager .session_hooks [session ]:
80
+ if hook in HookManager .active_hooks :
81
+ deactivated_hooks .add (hook )
80
82
HookManager .session_hooks [session ][hook ] = False
81
- deactivated_hooks .add (hook )
82
83
83
84
# Check if any other sessions rely on this hook
84
85
for hook in deactivated_hooks :
Original file line number Diff line number Diff line change 1
1
import json
2
2
import triton .profiler as proton
3
3
import pathlib
4
+ from triton .profiler .hooks .hook import HookManager
4
5
5
6
6
7
def test_profile_single_session (tmp_path : pathlib .Path ):
@@ -103,6 +104,14 @@ def test_hook(tmp_path: pathlib.Path):
103
104
temp_file = tmp_path / "test_hook.hatchet"
104
105
session_id0 = proton .start (str (temp_file .with_suffix ("" )), hook = "triton" )
105
106
proton .activate (session_id0 )
107
+ proton .activate (session_id0 )
108
+ assert len (
109
+ HookManager .active_hooks ) == 1 , ("Activate a session multiple times should maintain a single instance of hook" )
110
+ assert list (HookManager .session_hooks [session_id0 ].values ())[0 ] is True
111
+ proton .deactivate (session_id0 )
112
+ assert list (HookManager .session_hooks [session_id0 ].values ())[0 ] is False
113
+ assert len (HookManager .active_hooks ) == 0
114
+ # Deactivate a session multiple times should not raise an error
106
115
proton .deactivate (session_id0 )
107
116
proton .finalize (None )
108
117
assert temp_file .exists ()
You can’t perform that action at this time.
0 commit comments