@@ -85,36 +85,42 @@ def start(
8585 return libproton .start (name , context , data , backend )
8686
8787
88- def activate (session : Optional [int ] = 0 ) -> None :
88+ def activate (session : Optional [int ] = None ) -> None :
8989 """
9090 Activate the specified session.
9191 The profiling session will be active and data will be recorded.
9292
9393 Args:
94- session (int): The session ID of the profiling session. Defaults to 0 (the first session started. )
94+ session (int): The session ID of the profiling session. Defaults to None (all sessions )
9595
9696 Returns:
9797 None
9898 """
9999 if is_command_line () and session != 0 :
100100 raise ValueError ("Only one session can be activated when running from the command line." )
101- libproton .activate (session )
101+ if session is None :
102+ libproton .activate_all ()
103+ else :
104+ libproton .activate (session )
102105
103106
104- def deactivate (session : Optional [int ] = 0 ) -> None :
107+ def deactivate (session : Optional [int ] = None ) -> None :
105108 """
106109 Stop the specified session.
107110 The profiling session's data will still be in the memory, but no more data will be recorded.
108111
109112 Args:
110- session (int): The session ID of the profiling session. Defaults to 0 (the first session started. )
113+ session (int): The session ID of the profiling session. Defaults to None (all sessions )
111114
112115 Returns:
113116 None
114117 """
115118 if is_command_line () and session != 0 :
116119 raise ValueError ("Only one session can be deactivated when running from the command line." )
117- libproton .deactivate (session )
120+ if session is None :
121+ libproton .deactivate_all ()
122+ else :
123+ libproton .deactivate (session )
118124
119125
120126def finalize (session : Optional [int ] = None , output_format : str = "hatchet" ) -> None :
0 commit comments