Форум сайта python.su
26
Установил
redis 2.8.17 celery[redis]
#tasks.py from celery import Celery app = Celery('tasks', broker='redis://localhost:6379/0', backend='redis://localhost') @app.task def add(x, y): return x + y
In [1]: from tasks import add In [2]: r = add.delay(1,3) In [3]: r.status Out[3]: 'PENDING' In [4]: r.get(timeout=1) --------------------------------------------------------------------------- TimeoutError Traceback (most recent call last) <ipython-input-4-ade09ca12a13> in <module>() ----> 1 r.get(timeout=1) C:\Python27\lib\site-packages\celery\result.pyc in get(self, timeout, propagate, interval, no_ack, follow_parents, EXCEPTION_STATES, PROPAGATE_STATES) 167 interval=interval, 168 on_interval=on_interval, --> 169 no_ack=no_ack, 170 ) 171 if meta: C:\Python27\lib\site-packages\celery\backends\base.pyc in wait_for(self, task_id, timeout, interval, no_ack, on_interval) 223 time_elapsed += interval 224 if timeout and time_elapsed >= timeout: --> 225 raise TimeoutError('The operation timed out.') 226 227 def prepare_expires(self, value, type=None): TimeoutError: The operation timed out.
$ celery -A tasks worker --loglevel=info
[2015-01-09 15:02:25,540: WARNING/MainProcess] C:\Python27\lib\site-packages\celery\apps\worker.py:161: CDeprecationWarning:
Starting from version 3.2 Celery will refuse to accept pickle by default.
The pickle serializer is a security concern as it may give attackers
the ability to execute any command. It's important to secure
your broker from unauthorized access when using pickle, so we think
that enabling pickle should require a deliberate action and not be
the default choice.
If you depend on pickle then you should set a setting to disable this
warning and to be sure that everything will continue working
when you upgrade to Celery 3.2::
CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
You must only enable the serializers that you will actually use.
warnings.warn(CDeprecationWarning(W_PICKLE_DEPRECATED))
-------------- celery@sandbox v3.1.17 (Cipater)
---- **** -----
--- * *** * -- Windows-7-6.1.7601-SP1
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: tasks:0x3168cb0
- ** ---------- .> transport: redis://localhost:6379/0
- ** ---------- .> results: redis://localhost:6379/0
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ----
--- ***** ----- [queues]
-------------- .> celery exchange=celery(direct) key=celery
[tasks]
. tasks.add
[2015-01-09 15:02:25,694: INFO/MainProcess] Connected to redis://localhost:6379/0
[2015-01-09 15:02:25,717: INFO/MainProcess] mingle: searching for neighbors
[2015-01-09 15:02:26,757: INFO/MainProcess] mingle: all alone
[2015-01-09 15:02:26,770: WARNING/MainProcess] celery@sandbox ready.
[2015-01-09 15:03:00,915: INFO/MainProcess] Received task: tasks.add[23a79244-3713-49ec-b246-65791b1af1db]
[2015-01-09 15:03:00,936: INFO/MainProcess] Task tasks.add[23a79244-3713-49ec-b246-65791b1af1db] succeeded in 0.018000125885s: 9
ajib6ept@SANDBOX /c/tests
$ celery -A tasks worker --loglevel=info
[2015-01-09 15:04:32,867: WARNING/MainProcess] C:\Python27\lib\site-packages\celery\apps\worker.py:161: CDeprecationWarning:
Starting from version 3.2 Celery will refuse to accept pickle by default.
The pickle serializer is a security concern as it may give attackers
the ability to execute any command. It's important to secure
your broker from unauthorized access when using pickle, so we think
that enabling pickle should require a deliberate action and not be
the default choice.
If you depend on pickle then you should set a setting to disable this
warning and to be sure that everything will continue working
when you upgrade to Celery 3.2::
CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
You must only enable the serializers that you will actually use.
warnings.warn(CDeprecationWarning(W_PICKLE_DEPRECATED))
-------------- celery@sandbox v3.1.17 (Cipater)
---- **** -----
--- * *** * -- Windows-7-6.1.7601-SP1
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: tasks:0x3128230
- ** ---------- .> transport: redis://localhost:6379/0
- ** ---------- .> results: redis
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ----
--- ***** ----- [queues]
-------------- .> celery exchange=celery(direct) key=celery
[tasks]
. tasks.add
[2015-01-09 15:04:33,029: INFO/MainProcess] Connected to redis://localhost:6379/0
[2015-01-09 15:04:33,068: INFO/MainProcess] mingle: searching for neighbors
[2015-01-09 15:04:34,117: INFO/MainProcess] mingle: all alone
[2015-01-09 15:04:34,141: WARNING/MainProcess] celery@sandbox ready.
[2015-01-09 15:05:47,092: INFO/MainProcess] Received task: tasks.add[6ea3a7d3-3bf0-4b15-9797-d76bca772335]
[2015-01-09 15:05:47,109: INFO/MainProcess] Task tasks.add[6ea3a7d3-3bf0-4b15-9797-d76bca772335] succeeded in 0.0169999599457s: 2
ajib6ept@SANDBOX /c/tests
$ celery -A tasks worker --loglevel=info
[2015-01-09 15:09:01,660: WARNING/MainProcess] C:\Python27\lib\site-packages\celery\apps\worker.py:161: CDeprecationWarning:
Starting from version 3.2 Celery will refuse to accept pickle by default.
The pickle serializer is a security concern as it may give attackers
the ability to execute any command. It's important to secure
your broker from unauthorized access when using pickle, so we think
that enabling pickle should require a deliberate action and not be
the default choice.
If you depend on pickle then you should set a setting to disable this
warning and to be sure that everything will continue working
when you upgrade to Celery 3.2::
CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
You must only enable the serializers that you will actually use.
warnings.warn(CDeprecationWarning(W_PICKLE_DEPRECATED))
-------------- celery@sandbox v3.1.17 (Cipater)
---- **** -----
--- * *** * -- Windows-7-6.1.7601-SP1
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: tasks:0x2fc7d30
- ** ---------- .> transport: redis://localhost:6379/0
- ** ---------- .> results: disabled
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ----
--- ***** ----- [queues]
-------------- .> celery exchange=celery(direct) key=celery
[tasks]
. tasks.add
[2015-01-09 15:09:01,861: INFO/MainProcess] Connected to redis://localhost:6379/0
[2015-01-09 15:09:01,908: INFO/MainProcess] mingle: searching for neighbors
[2015-01-09 15:09:02,957: INFO/MainProcess] mingle: all alone
[2015-01-09 15:09:02,977: WARNING/MainProcess] celery@sandbox ready.
[2015-01-09 15:09:25,253: INFO/MainProcess] Received task: tasks.add[3c70f504-3ab4-4af0-8de3-f5517e55c4c1]
[2015-01-09 15:09:25,269: INFO/MainProcess] Task tasks.add[3c70f504-3ab4-4af0-8de3-f5517e55c4c1] succeeded in 0.0149998664856s: 3
ajib6ept@SANDBOX /c/tests
$ celery -A tasks worker --loglevel=info
[2015-01-09 15:10:04,460: WARNING/MainProcess] C:\Python27\lib\site-packages\celery\apps\worker.py:161: CDeprecationWarning:
Starting from version 3.2 Celery will refuse to accept pickle by default.
The pickle serializer is a security concern as it may give attackers
the ability to execute any command. It's important to secure
your broker from unauthorized access when using pickle, so we think
that enabling pickle should require a deliberate action and not be
the default choice.
If you depend on pickle then you should set a setting to disable this
warning and to be sure that everything will continue working
when you upgrade to Celery 3.2::
CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
You must only enable the serializers that you will actually use.
warnings.warn(CDeprecationWarning(W_PICKLE_DEPRECATED))
-------------- celery@sandbox v3.1.17 (Cipater)
---- **** -----
--- * *** * -- Windows-7-6.1.7601-SP1
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: tasks:0x2ff8d30
- ** ---------- .> transport: redis://localhost:6379/0
- ** ---------- .> results: redis://localhost
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ----
--- ***** ----- [queues]
-------------- .> celery exchange=celery(direct) key=celery
[tasks]
. tasks.add
[2015-01-09 15:10:04,625: INFO/MainProcess] Connected to redis://localhost:6379/0
[2015-01-09 15:10:04,644: INFO/MainProcess] mingle: searching for neighbors
[2015-01-09 15:10:05,769: INFO/MainProcess] mingle: all alone
[2015-01-09 15:10:05,790: WARNING/MainProcess] celery@sandbox ready.
[2015-01-09 15:10:16,173: INFO/MainProcess] Received task: tasks.add[16aea070-ac69-4f5b-8100-4e5fc87de5fe]
[2015-01-09 15:10:16,183: INFO/MainProcess] Task tasks.add[16aea070-ac69-4f5b-8100-4e5fc87de5fe] succeeded in 0.0090000629425s: 4
Отредактировано ajib6ept (Янв. 9, 2015 16:31:15)
Офлайн