Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(2)  |  Derive(0)  |  Import(0)
Used to initialize module-level variables that will be inherited by
subprocesses. On Windows, a multiprocessing.Manager object should only
be created within an "if __name__ == '__main__':" block. This function
must be called, otherwise every command that calls Command.Apply will fail.

        def InitializeMultiprocessingVariables():
  """
  Used to initialize module-level variables that will be inherited by
  subprocesses. On Windows, a multiprocessing.Manager object should only
  be created within an "if __name__ == '__main__':" block. This function
  must be called, otherwise every command that calls Command.Apply will fail.
  """
  # This list of global variables must exactly match the above list of
  # declarations.
  global manager, consumer_pools, task_queues, caller_id_lock, caller_id_counter
  global total_tasks, call_completed_map, global_return_values_map
  global need_pool_or_done_cond, caller_id_finished_count, new_pool_needed
  global current_max_recursive_level, shared_vars_map, shared_vars_list_map
  global class_map

  manager = multiprocessing.Manager()

  consumer_pools = []

  # List of all existing task queues - used by all pools to find the queue
  # that's appropriate for the given recursive_apply_level.
  task_queues = []

  # Used to assign a globally unique caller ID to each Apply call.
  caller_id_lock = manager.Lock()
  caller_id_counter = multiprocessing.Value('i', 0)

  # Map from caller_id to total number of tasks to be completed for that ID.
  total_tasks = ThreadAndProcessSafeDict(manager)

  # Map from caller_id to a boolean which is True iff all its tasks are
  # finished.
  call_completed_map = ThreadAndProcessSafeDict(manager)

  # Used to keep track of the set of return values for each caller ID.
  global_return_values_map = AtomicIncrementDict(manager)

  # Condition used to notify any waiting threads that a task has finished or
  # that a call to Apply needs a new set of consumer processes.
  need_pool_or_done_cond = manager.Condition()

  # Map from caller_id to the current number of completed tasks for that ID.
  caller_id_finished_count = AtomicIncrementDict(manager)

  # Used as a way for the main thread to distinguish between being woken up
  # by another call finishing and being woken up by a call that needs a new set
  # of consumer processes.
  new_pool_needed = multiprocessing.Value('i', 0)

  current_max_recursive_level = multiprocessing.Value('i', 0)

  # Map from (caller_id, name) to the value of that shared variable.
  shared_vars_map = AtomicIncrementDict(manager)
  shared_vars_list_map = ThreadAndProcessSafeDict(manager)

  # Map from caller_id to calling class.
  class_map = manager.dict()
        


src/g/s/gsutil-3.42/gslib/__main__.py   gsutil(Download)
    # called from within an "if __name__ == '__main__':" block.
    gslib.util.InitializeMultiprocessingVariables()
    gslib.command.InitializeMultiprocessingVariables()
  oauth2_client.InitializeMultiprocessingVariables()
 

src/g/s/gsutil-HEAD/gslib/__main__.py   gsutil(Download)
    # called from within an "if __name__ == '__main__':" block.
    gslib.util.InitializeMultiprocessingVariables()
    gslib.command.InitializeMultiprocessingVariables()
  oauth2_client.InitializeMultiprocessingVariables()