当前位置: 首页>>代码示例>>Python>>正文


Python django_rq.get_queue方法代码示例

本文整理汇总了Python中django_rq.get_queue方法的典型用法代码示例。如果您正苦于以下问题:Python django_rq.get_queue方法的具体用法?Python django_rq.get_queue怎么用?Python django_rq.get_queue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django_rq的用法示例。


在下文中一共展示了django_rq.get_queue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle_uploaded_file

# 需要导入模块: import django_rq [as 别名]
# 或者: from django_rq import get_queue [as 别名]
def handle_uploaded_file(request):
    """
    :param request: Django Request
    :type request: HttpRequest
    """
    f = request.FILES['package']
    temp_root = settings.TEMP_ROOT
    if not os.path.exists(temp_root):
        try:
            mkdir_p(temp_root)
        except OSError:
            pass
    package_temp_path = os.path.join(temp_root, str(uuid.uuid1()) + '.deb')
    with open(package_temp_path, 'wb+') as destination:
        for chunk in f.chunks():
            destination.write(chunk)
    os.chmod(package_temp_path, 0o755)
    if settings.ENABLE_REDIS is True:
        queue = django_rq.get_queue('high')
        return queue.enqueue(handle_uploaded_package, package_temp_path)
    else:
        return handle_uploaded_package(package_temp_path) 
开发者ID:82Flex,项目名称:DCRM,代码行数:24,代码来源:upload.py

示例2: __init__

# 需要导入模块: import django_rq [as 别名]
# 或者: from django_rq import get_queue [as 别名]
def __init__(self, config):
        """config is a dict that has an entry for queues"""
        if "queues" not in config:
            raise ConfigError(
                f"'queues' not present in autoscaler config:\nFound: {config}"
            )
        self.queues = [django_rq.get_queue(name) for name in config["queues"]]

        if "max_workers" not in config:
            raise ConfigError(
                f"'max_workers' not present in autoscaler config:\nFound: {config}"
            )
        self.max_workers = config["max_workers"]

        if "worker_reserve" not in config:
            raise ConfigError(
                f"'worker_reserve' not present in autoscaler config:\nFound: {config}"
            )
        self.worker_reserve = config["worker_reserve"] 
开发者ID:SFDO-Tooling,项目名称:MetaCI,代码行数:21,代码来源:autoscaling.py

示例3: handle_uploaded_image

# 需要导入模块: import django_rq [as 别名]
# 或者: from django_rq import get_queue [as 别名]
def handle_uploaded_image(request, package_id, gallery_slug):
    """
    :param package_id: str
    :param gallery_slug: str
    :param request: Django Request
    :type request: HttpRequest
    """
    i = request.FILES['image']
    temp_root = settings.TEMP_ROOT
    allow_ext = ['.png', '.jpg', '.gif']
    ext = os.path.splitext(i.name)[1].lower()
    if ext in allow_ext:
        if not os.path.exists(temp_root):
            mkdir_p(temp_root)
        image_temp_path = os.path.join(temp_root, str(uuid.uuid1()) + ext)
        with open(image_temp_path, 'wb+') as destination:
            for chunk in i.chunks():
                destination.write(chunk)
        os.chmod(image_temp_path, 0o755)
        content = {
            'id': package_id,
            'slug': gallery_slug,
            'path': image_temp_path
        }
        if settings.ENABLE_REDIS is True:
            queue = django_rq.get_queue('high')
            return queue.enqueue(handle_uploaded_screenshot, content)
        else:
            return handle_uploaded_screenshot(content)
    else:
        result_dict = {
            'success': False,
            'exception': _('Upload failed, unsupported file extension.')
        }
        return result_dict 
开发者ID:82Flex,项目名称:DCRM,代码行数:37,代码来源:upload.py

示例4: update_storage

# 需要导入模块: import django_rq [as 别名]
# 或者: from django_rq import get_queue [as 别名]
def update_storage(self):
        """
        Update control fields and write to deb files
        This method is executed async.
        """
        control = self.get_control_dict()
        path = self.storage.name
        if settings.ENABLE_REDIS is True:
            queue = django_rq.get_queue('high')
            update_job = queue.enqueue(write_to_package_job, control, path, self.id)
            return update_job
        else:
            write_to_package_job(control, path, self.id)
        return None 
开发者ID:82Flex,项目名称:DCRM,代码行数:16,代码来源:version.py

示例5: batch_hash_update

# 需要导入模块: import django_rq [as 别名]
# 或者: from django_rq import get_queue [as 别名]
def batch_hash_update(self, request, queryset):
        """
        :type queryset: QuerySet
        """
        if settings.ENABLE_REDIS is True:
            queue = django_rq.get_queue('high')
            queue.enqueue(hash_update_job, queryset)
            self.message_user(request, _("Hash updating job has been added to the \"high\" queue."))
        else:
            hash_update_job(queryset)
            self.message_user(request, _("Hash updating job has been finished.")) 
开发者ID:82Flex,项目名称:DCRM,代码行数:13,代码来源:version.py

示例6: job_link

# 需要导入模块: import django_rq [as 别名]
# 或者: from django_rq import get_queue [as 别名]
def job_link(self, obj):
        if obj.job_id is None:
            if obj.is_finished:
                return mark_safe("<img src=\"/static/admin/img/icon-yes.svg\" alt=\"True\" /> %s" % _('Finished'))
            else:
                return mark_safe("<img src=\"/static/admin/img/icon-unknown.svg\" alt=\"Unknown\" /> %s" % _('Unknown'))
        m_job = queues.get_queue('high').fetch_job(obj.job_id)
        if m_job is None:
            return _('No such job')
        if m_job.is_failed:
            status_str = mark_safe("<img src=\"/static/admin/img/icon-no.svg\" alt=\"False\" /> %s" % _('Failed'))
        elif m_job.is_finished:
            if obj.is_finished:
                status_str = mark_safe("<img src=\"/static/admin/img/icon-yes.svg\" alt=\"True\" /> %s" % _('Finished'))
            else:
                status_str = mark_safe(
                    "<img src=\"/static/admin/img/icon-unknown.svg\" alt=\"Unknown\" /> %s" % _('Unknown'))
        else:
            status_str = mark_safe("<img src=\"/static/img/icon-loading.svg\" width=\"13\" alt=\"Loading\" "
                                   "onload=\"setTimeout(function () { window.location.reload(); }, 2000);\" /> "
                                   "%s" % _("Processing..."))
        return mark_safe('<a href="%s" target="_blank">%s</a>' % (
            reverse('rq_job_detail', kwargs={
                'queue_index': 1,
                'job_id': m_job.id
            }),
            status_str
        )) 
开发者ID:82Flex,项目名称:DCRM,代码行数:30,代码来源:build.py

示例7: test_makemessages_django_rq_single_run

# 需要导入模块: import django_rq [as 别名]
# 或者: from django_rq import get_queue [as 别名]
def test_makemessages_django_rq_single_run(self):
            queue = get_queue('default')
            queue.enqueue(tasks.makemessages_task)

            get_worker().work(burst=True) 
开发者ID:COEXCZ,项目名称:django-translation-manager,代码行数:7,代码来源:tests.py

示例8: test_makemessages_django_tq_more_jobs

# 需要导入模块: import django_rq [as 别名]
# 或者: from django_rq import get_queue [as 别名]
def test_makemessages_django_tq_more_jobs(self):
            queue = get_queue('default')
            queue.enqueue(tasks.makemessages_task)
            queue.enqueue(tasks.makemessages_task)
            queue.enqueue(tasks.makemessages_task)

            get_worker().work(burst=True) 
开发者ID:COEXCZ,项目名称:django-translation-manager,代码行数:9,代码来源:tests.py

示例9: __init__

# 需要导入模块: import django_rq [as 别名]
# 或者: from django_rq import get_queue [as 别名]
def __init__(self):
        super().__init__()

        self.queue = django_rq.get_queue('wagtail_localize_pontoon.sync') 
开发者ID:mozilla,项目名称:donate-wagtail,代码行数:6,代码来源:pontoon.py

示例10: start_build

# 需要导入模块: import django_rq [as 别名]
# 或者: from django_rq import get_queue [as 别名]
def start_build(build, lock_id=None):
    queue = django_rq.get_queue(build.plan.queue)
    result = queue.enqueue(
        run_build, build.id, lock_id, job_timeout=build.plan.build_timeout
    )
    build.task_id_check = None
    build.task_id_run = result.id
    build.save()
    autoscale()
    return result 
开发者ID:SFDO-Tooling,项目名称:MetaCI,代码行数:12,代码来源:tasks.py


注:本文中的django_rq.get_queue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。