def create_celery_file(self, input_type):
    """ Creates the Celery configuration file describing 
        queues and exchanges for an application. Uses either
        the queue.yaml/queue.xml input or what was stored in the 
        datastore to create the celery file. 

    Args:
      input_type: Whether to use the config file or the 
                  database queue info. Default: config file.
    Returns:
      A string representing the full path location of the 
      configuration file.
    """
    queue_info = self._queue_info_file
    if input_type == self.QUEUE_INFO_DB:
      queue_info = self._queue_info_db 
 
    celery_queues = []
    celery_annotations = []
    for queue in queue_info['queue']:
      if 'mode' in queue and queue['mode'] == "pull":
        continue # celery does not handle pull queues
      celery_queue_name = \
        TaskQueueConfig.get_celery_queue_name(self._app_id, queue['name'])
      celery_queues.append("Queue('" + celery_queue_name + \
         "', Exchange('" + self._app_id + \
         "'), routing_key='" + celery_queue_name  + "'),")

      rate_limit = self.DEFAULT_RATE
      if 'rate' in queue:
        rate_limit = queue['rate']

      annotation_name = \
        TaskQueueConfig.get_celery_annotation_name(self._app_id,
                                                   queue['name'])
      celery_annotations.append("'" + annotation_name + \
         "': {'rate_limit': '" + rate_limit + "'},")

    celery_queues = '\n'.join(celery_queues)
    celery_annotations = '\n'.join(celery_annotations)
    config = \
"""
from kombu import Exchange
from kombu import Queue
CELERY_QUEUES = (
"""
    config += celery_queues
    config += \
"""
)
CELERY_ANNOTATIONS = {
"""
    config += celery_annotations
    config += \
"""
}
# Everytime a task is enqueued a temporary queue is created to store
# results into rabbitmq. This can be bad in a high enqueue environment
# We use the following to make sure these temp queues are not created. 
# See http://stackoverflow.com/questions/7144025/temporary-queue-made-in-celery
# for more information on this issue.
CELERY_IGNORE_RESULT = True
CELERY_STORE_ERRORS_EVEN_IF_IGNORED = False

# One month expiration date because a task can be deferred that long.
CELERY_AMQP_TASK_RESULT_EXPIRES = 2678400

# Disable prefetching for celery workers. If tasks are small in duration this
# should be set to a higher value (64-128) for increased performance.
# See: http://celery.readthedocs.org/en/latest/userguide/optimizing.html#worker-settings
CELERYD_PREFETCH_MULTIPLIER = 1
"""
    config_file = self._app_id + ".py" 
    file_io.write(self.CELERY_CONFIG_DIR + config_file, config)
    return self.CELERY_CONFIG_DIR + config_file
dataset/ETHPy150Open AppScale/appscale/AppTaskQueue/tq_config.py/TaskQueueConfig.create_celery_file/original