Python multiprocessing 模块,html() 实例源码

我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用multiprocessing.html()

项目:pynit    作者:traverseda    | 项目源码 | 文件源码
def background(func):
   """
   Will run you function in the background.
   Please note that there are probably ways to abuse this to run code in the parent.
   In the future, we need to get a serilization method that isn't "pickle" running, for security.

   It returns a "Service" object, which right now is pretty much identical to a multiprocess.Process object

   TODO: Replace the built in pickle? serialization with something else. Maybe rpyc's brine.
   http://stackoverflow.com/a/13019405
   https://docs.python.org/2/library/multiprocessing.html#connection-objects
   """
   def func_wrapper(*args,**kwargs):
       p = Service(target = func, args=args, kwargs=kwargs, daemon = False)
       return p
   return func_wrapper
项目:blackmamba    作者:zrzka    | 项目源码 | 文件源码
def calculate_pool_chunksize(num_checkers, num_jobs):
    """Determine the chunksize for the multiprocessing Pool.

    - For chunksize, see: https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.Pool.imap  # noqa
    - This formula, while not perfect, aims to give each worker two batches of
      work.
    - See: https://gitlab.com/pycqa/flake8/merge_requests/156#note_18878876
    - See: https://gitlab.com/pycqa/flake8/issues/265
    """
    return max(num_checkers // (num_jobs * 2), 1)