code: def check_basic(pool):
      state = pool.__state__
      res = pool.map(squared, range(2))
      assert res == [0, 1]
      res = pool.map(squared, range(2))
      assert res == [0, 1]
  
      # join needs to be called after close
      try:
          pool.join()
      except PoolRunningError:
          pass
      else:
          raise AssertionError
      pool.close()
  
      # map fails when closed
      try:
          pool.map(squared, range(2))
      except PoolClosedError:
          pass
      else:
          raise AssertionError
  
      obj = pool._serve()
      assert obj in list(state.values())
  
      # serve has no effect on closed
      try:
          pool.map(squared, range(2))
      except PoolClosedError:
          pass
      else:
          raise AssertionError
  
      # once restarted, map works
      pool.restart()
      res = pool.map(squared, range(2))
      assert res == [0, 1]
  
      # assorted kicking of the tires...
      pool.close()
      pool.restart()
      res = pool.map(squared, range(2))
      assert res == [0, 1]
      pool.close()
      pool.join()
      pool._serve()
      try:
          pool.map(squared, range(2))
      except PoolClosedError:
          pass
      else:
          raise AssertionError
  
      pool.join()
      try:
          pool.map(squared, range(2))
      except PoolClosedError:
          pass
      else:
          raise AssertionError
  
      pool.clear()
      res = pool.map(squared, range(2))
      assert res == [0, 1]
  
      try:
          pool.join()
      except PoolRunningError:
          pass
      else:
          raise AssertionError
  
      pool.close()
      pool.join()
      try:
          pool.map(squared, range(2))
      except PoolClosedError:
          pass
      else:
          raise AssertionError
      pool.restart()
      res = pool.map(squared, range(2))
      assert res == [0, 1]
      pool.close()
      pool.join()
      try:
          pool.map(squared, range(2))
      except PoolClosedError:
          pass
      else:
          raise AssertionError
  
      pool._serve()
      try:
          pool.map(squared, range(2))
      except PoolClosedError:
          pass
      else:
          raise AssertionError
  
      pool.restart()
      res = pool.map(squared, range(2))
      assert res == [0, 1]
      pool.close()
      try:
          pool.map(squared, range(2))
      except PoolClosedError:
          pass
      else:
          raise AssertionError
  
      pool.restart()
      res = pool.map(squared, range(2))
      assert res == [0, 1]
      obj = pool._serve()
      assert obj in list(state.values())
      assert len(state) == 1
      pool.terminate()
      pool.clear()
      assert len(state) == 0
      return
  
file_path: pathos/pathos/tests/test_join.py
imports: from pathos.parallel import *
  from pathos.multiprocessing import *
  from pathos.threading import *
  from pathos.helpers import cpu_count
  import sys
  import dill
label_desc: Use image node_id 2 for calling a global function with example usage: check_basic(pool) without return types