MCPcopy Create free account
hub / github.com/catboost/catboost / test_memoize_thread_local

Function test_memoize_thread_local

library/python/func/ut/test_func.py:165–188  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

163
164
165def test_memoize_thread_local():
166 class Counter(object):
167 def __init__(self, s):
168 self.val = s
169
170 def inc(self):
171 self.val += 1
172 return self.val
173
174 @func.memoize(thread_local=True)
175 def get_counter(start):
176 return Counter(start)
177
178 def th_inc():
179 assert get_counter(0).inc() == 1
180 assert get_counter(0).inc() == 2
181 assert get_counter(10).inc() == 11
182 assert get_counter(10).inc() == 12
183
184 th_inc()
185
186 th = threading.Thread(target=th_inc)
187 th.start()
188 th.join()
189
190
191def test_memoize_not_thread_safe():

Callers

nothing calls this directly

Calls 3

th_incFunction · 0.85
startMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected