code: def test_memoize_not_thread_safe_concurrent():
      class Counter(object):
          def __init__(self, s):
              self.val = s
  
          def inc(self):
              self.val += 1
              return self.val
  
      @func.memoize(thread_safe=False)
      def io_job(n):
          time.sleep(0.1)
          return Counter(n)
  
      def worker():
          io_job(100).inc()
  
      th1 = threading.Thread(target=worker)
      th2 = threading.Thread(target=worker)
      th3 = threading.Thread(target=worker)
  
      th1.start()
      time.sleep(0.05)
      th2.start()
  
      th1.join()
      assert io_job(100).inc() == 100 + 2
  
      th3.start()
      # th3 instantly got counter from memory
      assert io_job(100).inc() == 100 + 4
  
      th2.join()
      # th2 shoud increase th1 counter
      assert io_job(100).inc() == 100 + 6
  
file_path: catboost/library/python/func/ut/test_func.py
imports: import pytest
  import multiprocessing
  import random
  import threading
  import time
  import library.python.func
label_desc: Use image node_id 9 for calling a global function with example usage: test_memoize_not_thread_safe_concurrent() and returns: Counter, self