コード例 #1
0
    def on_apply(self,
                 target,
                 args=None,
                 kwargs=None,
                 callback=None,
                 accept_callback=None,
                 timeout=None,
                 timeout_callback=None,
                 **_):

        # TaskResult.task_pending(args)
        return GeventTaskPool.on_apply(self, target, args, kwargs, callback,
                                       accept_callback, timeout,
                                       timeout_callback, **_)
コード例 #2
0
    def test_pool(self):
        with mock_module(*gevent_modules):
            with patch_many('gevent.spawn_raw',
                            'gevent.pool.Pool') as (spawn_raw, Pool):
                x = TaskPool()
                x.on_start()
                x.on_stop()
                x.on_apply(Mock())
                x._pool = None
                x.on_stop()

                x._pool = Mock()
                x._pool._semaphore.counter = 1
                x._pool.size = 1
                x.grow()
                self.assertEqual(x._pool.size, 2)
                self.assertEqual(x._pool._semaphore.counter, 2)
                x.shrink()
                self.assertEqual(x._pool.size, 1)
                self.assertEqual(x._pool._semaphore.counter, 1)

                x._pool = [4, 5, 6]
                self.assertEqual(x.num_processes, 3)
コード例 #3
0
ファイル: test_gevent.py プロジェクト: huyngopt1994/celery-1
    def test_pool(self):
        x = TaskPool()
        x.on_start()
        x.on_stop()
        x.on_apply(Mock())
        x._pool = None
        x.on_stop()

        x._pool = Mock()
        x._pool._semaphore.counter = 1
        x._pool.size = 1
        x.grow()
        assert x._pool.size == 2
        assert x._pool._semaphore.counter == 2
        x.shrink()
        assert x._pool.size, 1
        assert x._pool._semaphore.counter == 1

        x._pool = [4, 5, 6]
        assert x.num_processes == 3
コード例 #4
0
ファイル: test_gevent.py プロジェクト: bryson/celery
    def test_pool(self):
        x = TaskPool()
        x.on_start()
        x.on_stop()
        x.on_apply(Mock())
        x._pool = None
        x.on_stop()

        x._pool = Mock()
        x._pool._semaphore.counter = 1
        x._pool.size = 1
        x.grow()
        assert x._pool.size == 2
        assert x._pool._semaphore.counter == 2
        x.shrink()
        assert x._pool.size, 1
        assert x._pool._semaphore.counter == 1

        x._pool = [4, 5, 6]
        assert x.num_processes == 3
コード例 #5
0
ファイル: test_gevent.py プロジェクト: Crowdbooster/celery
    def test_pool(self):
        with mock_module(*gevent_modules):
            with patch_many('gevent.spawn_raw', 'gevent.pool.Pool') as (
                    spawn_raw, Pool):
                x = TaskPool()
                x.on_start()
                x.on_stop()
                x.on_apply(Mock())
                x._pool = None
                x.on_stop()

                x._pool = Mock()
                x._pool._semaphore.counter = 1
                x._pool.size = 1
                x.grow()
                self.assertEqual(x._pool.size, 2)
                self.assertEqual(x._pool._semaphore.counter, 2)
                x.shrink()
                self.assertEqual(x._pool.size, 1)
                self.assertEqual(x._pool._semaphore.counter, 1)

                x._pool = [4, 5, 6]
                self.assertEqual(x.num_processes, 3)
コード例 #6
0
 def test_num_processes(self):
     pool = TaskPool(10)
     pool.start()
     pool.apply_async(lambda x: x, (2, ), {})
     self.assertEqual(pool.num_processes, 1)
コード例 #7
0
 def test_shrink_many(self):
     pool = TaskPool(10)
     pool.start()
     self.assertEqual(pool._pool.size, 10)
     pool.shrink(2)
     self.assertEqual(pool._pool.size, 8)
コード例 #8
0
 def test_grow_many(self):
     pool = TaskPool(10)
     pool.start()
     self.assertEqual(pool._pool.size, 10)
     pool.grow(2)
     self.assertEqual(pool._pool.size, 12)
コード例 #9
0
    def test_pool(self):
        x = TaskPool()
        x.on_start()
        x.on_stop()
        x.on_apply(Mock())
        x._pool = None
        x.on_stop()

        x._pool = Mock()
        x._pool._semaphore.counter = 1
        x._pool.size = 1
        x.grow()
        self.assertEqual(x._pool.size, 2)
        self.assertEqual(x._pool._semaphore.counter, 2)
        x.shrink()
        self.assertEqual(x._pool.size, 1)
        self.assertEqual(x._pool._semaphore.counter, 1)

        x._pool = [4, 5, 6]
        self.assertEqual(x.num_processes, 3)
コード例 #10
0
ファイル: test_gevent.py プロジェクト: delantai/celery
    def test_pool(self):
        x = TaskPool()
        x.on_start()
        x.on_stop()
        x.on_apply(Mock())
        x._pool = None
        x.on_stop()

        x._pool = Mock()
        x._pool._semaphore.counter = 1
        x._pool.size = 1
        x.grow()
        self.assertEqual(x._pool.size, 2)
        self.assertEqual(x._pool._semaphore.counter, 2)
        x.shrink()
        self.assertEqual(x._pool.size, 1)
        self.assertEqual(x._pool._semaphore.counter, 1)

        x._pool = [4, 5, 6]
        self.assertEqual(x.num_processes, 3)