當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。