import multiprocessing
import time
from opencc import OpenCC

class a(object):
  def func1(self, i):
    return i

  def test(self, total):
    multiprocessing.freeze_support()  # for windows, RuntimeError
    pool = multiprocessing.Pool(1)

    startime = time.time()
    result = []
    for i in range(total):
      res = pool.apply_async(self.func1, args=(i,))
      result.append(res)

    pool.close()
    self.aa = OpenCC('s2twp')

    for idx, r in enumerate(result,start=1):
      print (r.get())
      print('{}/{}'.format(idx, total), end='\r')
    print ('')
    print ('time=', time.time()-startime)

if __name__ == '__main__':
  o = a()
  o.test(700)