File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -133,22 +133,28 @@ cdef class LineProfiler:
133133 self .code_map[code] = {}
134134 self .functions.append(func)
135135
136+ property enable_count :
137+ def __get__ (self ):
138+ if not hasattr (self .threaddata, ' enable_count' ):
139+ self .threaddata.enable_count = 0
140+ return self .threaddata.enable_count
141+ def __set__ (self , value ):
142+ self .threaddata.enable_count = value
143+
136144 def enable_by_count (self ):
137145 """ Enable the profiler if it hasn't been enabled before.
138146 """
139- if not hasattr (self .threaddata, ' enable_count' ):
140- self .threaddata.enable_count = 0
141- if self .threaddata.enable_count == 0 :
147+ if self .enable_count == 0 :
142148 self .enable()
143- self .threaddata. enable_count += 1
149+ self .enable_count += 1
144150
145151 def disable_by_count (self ):
146152 """ Disable the profiler if the number of disable requests matches the
147153 number of enable requests.
148154 """
149- if self .threaddata. enable_count > 0 :
150- self .threaddata. enable_count -= 1
151- if self .threaddata. enable_count == 0 :
155+ if self .enable_count > 0 :
156+ self .enable_count -= 1
157+ if self .enable_count == 0 :
152158 self .disable()
153159
154160 def __enter__ (self ):
You can’t perform that action at this time.
0 commit comments