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


Python Queue.create方法代码示例

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


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

示例1: handle

# 需要导入模块: from pq.queue import Queue [as 别名]
# 或者: from pq.queue.Queue import create [as 别名]
    def handle(self, *args, **options):
        """
        The actual logic of the command. Subclasses must implement
        this method.
        """
        from pq.queue import Queue, SerialQueue

        verbosity = int(options.get('verbosity', 1))
        func = args[0]
        args = args[1:]
        async = not options.get('sync')
        timeout = options.get('timeout')
        queue = options.get('queue')
        conn = options.get('conn')
        if options['serial']:
            queue = queue or 'serial'
            q = SerialQueue.create(queue, connection=conn)
        else:
            queue = queue or 'default'
            q = Queue.create(queue, connection=conn)
        if timeout:
            job = q.enqueue_call(func, args=args, timeout=timeout, async=async)
        else:
            job = q.enqueue_call(func, args=args, async=async)
        if verbosity and job.id:
            print('Job %i created' % job.id)
        elif verbosity:
            print('Job complete')
开发者ID:oinopion,项目名称:django-pq,代码行数:30,代码来源:pqenqueue.py

示例2: handle

# 需要导入模块: from pq.queue import Queue [as 别名]
# 或者: from pq.queue.Queue import create [as 别名]
    def handle(self, *args, **options):
        """
        The actual logic of the command. Subclasses must implement
        this method.

        """
        from django.conf import settings
        from pq.queue import Queue, SerialQueue
        from pq.worker import Worker

        sentry_dsn = options.get('sentry_dsn')
        if not sentry_dsn:
            sentry_dsn = settings.SENTRY_DSN if hasattr(settings, 'SENTRY_DSN') else None

        verbosity = int(options.get('verbosity'))
        queues = []
        for queue in args:
            q = Queue.objects.get(name=queue)
            if q.serial:
                queues.append(SerialQueue.create(name=queue))
            else:
                queues.append(Queue.create(name=queue))
        w = Worker.create(queues, name=options.get('name'), connection=options['connection'])

        # Should we configure Sentry?
        if sentry_dsn:
            from raven import Client
            from pq.contrib.sentry import register_sentry
            client = Client(sentry_dsn)
            register_sentry(client, w)

        w.work(burst=options['burst'])
开发者ID:vilos,项目名称:django-pq,代码行数:34,代码来源:pqworker.py

示例3: test_queue_creation_conflict_issue2

# 需要导入模块: from pq.queue import Queue [as 别名]
# 或者: from pq.queue.Queue import create [as 别名]
 def test_queue_creation_conflict_issue2(self):
     """Ordinary queue shouldn't ever become a serial queue"""
     q = Queue.create()
     self.assertFalse(q.serial)
     q.enqueue(do_nothing)
     self.q.enqueue(do_nothing)
     w = Worker([q, self.q])
     w.work(burst=True)
开发者ID:vladignatyev,项目名称:django-pq,代码行数:10,代码来源:test_queue_serial.py

示例4: handle

# 需要导入模块: from pq.queue import Queue [as 别名]
# 或者: from pq.queue.Queue import create [as 别名]
    def handle(self, *args, **options):
        """
        The actual logic of the command. Subclasses must implement
        this method.
        """
        from pq.queue import Queue, SerialQueue

        verbosity = int(options.get('verbosity', 1))
        func = args[1]
        if args[0].lower() == 'now':
            at = now()
        else:
            at = parser.parse(args[0])
        if not at.tzinfo:
            at = at.replace(tzinfo=get_default_timezone())

        args = args[2:]
        if options.get('mtwtf'):
            weekdays = (0, 1, 2, 3, 4)
        else:
            weekdays = (
                options.get('mo'),
                options.get('tu'),
                options.get('we'),
                options.get('th'),
                options.get('fr'),
                options.get('sa'),
                options.get('su'),
            )

            weekdays = [w for w in weekdays if isinstance(w, integer_types)]
        timeout = options.get('timeout')
        queue = options.get('queue')
        conn = options.get('conn')
        if options['serial']:
            queue = queue or 'serial'
            q = SerialQueue.create(queue, connection=conn, scheduled=True)
        else:
            queue = queue or 'default'
            q = Queue.create(queue, connection=conn, scheduled=True)
        job = q.schedule_call(
            at, func,
            args=args,
            timeout=timeout,
            repeat=options['repeat'],
            interval=options['interval'],
            between=options['between'],
            weekdays=weekdays
        )
        if verbosity:
            print('Job %i created' % job.id)
开发者ID:oinopion,项目名称:django-pq,代码行数:53,代码来源:pqschedule.py

示例5: pq

# 需要导入模块: from pq.queue import Queue [as 别名]
# 或者: from pq.queue.Queue import create [as 别名]
def pq(function, *args, **kwargs):
    '''
    Adds ``function`` to the `django-pq <https://github.com/bretth/django-pq>`_
    default queue, with any passed in
    ``args`` and ``kwargs`` It will create this queue if it doesn't exist.
    '''
    from pq.queue import Queue
    queue = Queue.create()
    # Try to create the queue table, but if the database isn't set up yet
    # then don't create it
    try:
        queue.save()
    except DatabaseError:
        pass

    queue.enqueue(function, *args, **kwargs)
开发者ID:vccabral,项目名称:django-simpleimages,代码行数:18,代码来源:callers.py

示例6: handle

# 需要导入模块: from pq.queue import Queue [as 别名]
# 或者: from pq.queue.Queue import create [as 别名]
 def handle(self, *args, **options):
     """
     The actual logic of the command. Subclasses must implement
     this method.
     """
     from pq.queue import Queue, SerialQueue
     verbosity = int(options.get('verbosity', 1))
     timeout = options.get('timeout')
     for queue in args:
         if options['serial']:
             q = SerialQueue.create(queue)
         else:
             q = Queue.create(queue)
         q.connection = options.get('conn')
         q.scheduled = options.get('scheduled')
         if timeout:
             q.default_timeout = timeout
         q.save()
开发者ID:JirkaV,项目名称:django-pq,代码行数:20,代码来源:pqcreate.py

示例7: handle

# 需要导入模块: from pq.queue import Queue [as 别名]
# 或者: from pq.queue.Queue import create [as 别名]
    def handle(self, *args, **options):
        """
        The actual logic of the command. Subclasses must implement
        this method.
        """
        from pq.queue import Queue, SerialQueue

        func = args[1]
        if args[0].lower() == 'now':
            at = now()
        else:
            at = parser.parse(args[0])
        if not at.tzinfo:
            at = at.replace(tzinfo=get_default_timezone())

        args = args[2:]
        if options.get('mtwtf'):
            weekdays = (0,1,2,3,4)
        else:
            weekdays = (
                options.get('mo'),
                options.get('tu'),
                options.get('we'),
                options.get('th'),
                options.get('fr'),
                options.get('sa'),
                options.get('su'),
                )
            weekdays = [w for w in weekdays if w]
        timeout = options.get('timeout')
        queue = options.get('queue')
        if options['serial']:
            queue = queue or 'serial'
            q = SerialQueue.create(queue)
        else:
            queue = queue or 'default'
            q = Queue.create(queue)
        q.schedule_call(at, func, args=args, 
            timeout=timeout,
            repeat=options['repeat'],
            interval=options['interval'],
            between=options['between'],
            weekdays=weekdays
            )
开发者ID:vilos,项目名称:django-pq,代码行数:46,代码来源:pqschedule.py

示例8: handle

# 需要导入模块: from pq.queue import Queue [as 别名]
# 或者: from pq.queue.Queue import create [as 别名]
    def handle(self, *args, **options):
        """
        The actual logic of the command. Subclasses must implement
        this method.
        """
        from pq.queue import Queue, SerialQueue

        func = args[0]
        args = args[1:]
        timeout = options.get("timeout")
        queue = options.get("queue")
        if options["serial"]:
            queue = queue or "serial"
            q = SerialQueue.create(queue)
        else:
            queue = queue or "default"
            q = Queue.create(queue)
        if timeout:
            q.enqueue(func, *args, timeout=timeout)
        else:
            q.enqueue(func, *args)
开发者ID:vilos,项目名称:django-pq,代码行数:23,代码来源:pqenqueue.py

示例9: test_default_queue_create_multiple

# 需要导入模块: from pq.queue import Queue [as 别名]
# 或者: from pq.queue.Queue import create [as 别名]
 def test_default_queue_create_multiple(self):
     queue = Queue.create()
     self.assertEqual(queue.name, 'default')
     queue = SerialQueue.create()
     self.assertEqual(queue.name, 'default (serial)')
开发者ID:vladignatyev,项目名称:django-pq,代码行数:7,代码来源:test_queue_serial.py


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