def __init__(self, logger=None):
     """
     :param logger:
         The logger to use. If you instantiate this class more than once, you should use the same logger
         to avoid duplicate log entries.
     :type logger:
         :class:`Logger`
     """
     super(LoggingNetwork, self).__init__()
     self._logger = logger or setup_logging(name=self.LOGGER_NAME)
 def __init__(self, logger=None):
     """
     :param logger:
         The logger to use. If you instantiate this class more than once, you should use the same logger
         to avoid duplicate log entries.
     :type logger:
         :class:`Logger`
     """
     super(LoggingNetwork, self).__init__()
     self._logger = logger or setup_logging(name=self.LOGGER_NAME)
def worker():
    # Set up a logging network, but use the LoggingProxy so we can see which PID is generating messages
    logger = getLogger('boxsdk.network.{0}'.format(getpid()))
    setup_logging(name=logger.name)

    # Create a coop oauth2 instance.
    # Tokens will be retrieved from and stored to the multiprocessing Namespace.
    # A multiprocessing Lock will be used to synchronize token refresh.
    # The tokens from the master process are used for initial auth.
    # Whichever process needs to refresh
    oauth2 = CooperativelyManagedOAuth2(
        retrieve_tokens=_retrive_tokens,
        client_id=CLIENT_ID,
        client_secret=CLIENT_SECRET,
        store_tokens=_store_tokens,
        access_token=tokens.access,
        refresh_token=tokens.refresh,
        refresh_lock=refresh_lock,
    )
    client = Client(oauth2)
    _do_work(client)
def worker():
    # Set up a logging network, but use the LoggingProxy so we can see which PID is generating messages
    logger = setup_logging(name='boxsdk.network.{0}'.format(getpid()))
    logger_proxy = LoggerProxy(logger)
    logging_network = LoggingNetwork(logger)

    # Create a coop oauth2 instance.
    # Tokens will be retrieved from and stored to the multiprocessing Namespace.
    # A multiprocessing Lock will be used to synchronize token refresh.
    # The tokens from the master process are used for initial auth.
    # Whichever process needs to refresh
    oauth2 = CooperativelyManagedOAuth2(
        retrieve_tokens=_retrive_tokens,
        client_id=CLIENT_ID,
        client_secret=CLIENT_SECRET,
        store_tokens=_store_tokens,
        network_layer=logging_network,
        access_token=tokens.access,
        refresh_token=tokens.refresh,
        refresh_lock=refresh_lock,
    )
    client = Client(oauth2, network_layer=logging_network)
    _do_work(client)