Package: celery-pubsub
celery-pubsub 1.0.2Publish and Subscribe with CelerySupported dependenciesPythonCelery 3Celery 4Celery 52.73.53.63.73.83.93.10pypy 2.7pypy 3.6Basic usageimportceleryimportcelery_pubsub@celery.taskdefmy_task_1(*args,**kwargs):return"task 1 done"@celery.taskdefmy_task_2(*args,**kwargs):return"task 2 done"# First, let's subscribecelery_pubsub.subscribe('some.topic',my_task_1)celery_pubsub.subscribe('some.topic',my_task_2)# Now, let's publish somethingres=celery_pubsub.publish('some.topic',data='something',value=42)# We can get the results if we want to (and if the tasks returned something)# But in pub/sub, usually, there's no result.print(res.get())# This will get nowhere, as no task subscribed to this topicres=celery_pubsub.publish('nowhere',data='something else',value=23)Advanced usageWildcards can be used in topic names:*matches any one groupsome.*.testwill matchsome.awesome.test,some.random.testbut notsome.pretty.cool.test,elsewhereorhere.some.up.testsome.*will matchsome.testandsome.thingbut it won't
matchsomeorsome.testy.test#matches any number of groupssome.#.testwill matchsome.awesome.test,some.random.test,some.pretty.cool.testbut notelsewhereorhere.some.up.testsome.#will match anything that starts withsome., such assome.very.specific.topic.indeed#will match anything# Let's subscribecelery_pubsub.subscribe('some.*',my_task_1)celery_pubsub.subscribe('some.*.test',my_task_2)celery_pubsub.subscribe('some.#',my_task_3)celery_pubsub.subscribe('#',my_task_4)celery_pubsub.subscribe('some.beep',my_task_5)# it's okay to have more than one task on the same topiccelery_pubsub.subscribe('some.beep',my_task_6)# Let's publishcelery_pubsub.publish('nowhere',4)# task 4 onlycelery_pubsub.publish('some',8)# task 4 onlycelery_pubsub.publish('some.thing',15)# tasks 1, 3 and 4celery_pubsub.publish('some.true.test',16)# tasks 2, 3 and 4celery_pubsub.publish('some.beep',23)# tasks 1, 3, 4, 5 and 6celery_pubsub.publish('some.very.good.test',42)# tasks 3 and 4# And if you want to publish synchronously:celery_pubsub.publish_now('some.very.good.test',42)# tasks 3 and 4# You can unsubscribe toocelery_pubsub.unsubscribe('#',my_task_4)# Now, task 4 will not be called anymorecelery_pubsub.publish('some.very.good.test',42)# task 3 onlyChangelog1.0.2Add stubs file for type hinting.1.0.1ChangedREADME.rsttoREADME.md.Added better badges to show the supported status for each Celery & Python version.1.0.0Flexible requirements (no more pinned). Better to support a wide range of environments.Changed test framework from nose to pytest.Flake8Support for Python 3.9 and 3.10.0.2.1Performance: Internally uses asetto store the subscribed tasks.Updated Codeclimate as theold reporter <https://github.com/codeclimate/python-test-reporter>_ is deprecated.Pinned requirements' dependency versions.celery 4.3.0 -> 4.4.0kombu 4.6.4 -> 4.6.7billiard 3.6.1.0 -> 3.6.2.0codeclimate-test-reporter 0.2.3 -> removed!0.2.0Removed Python 3.4 support. Reason: no longer supported by Kombu 4.6+.Officially supported by Python 3.8.Pinned requirements' dependency versions.celery 4.2.1 -> 4.3.0kombu 4.2.1 -> 4.6.4billiard 3.5.0.4 -> 3.6.1.0vine 1.1.4 -> 1.3.00.1.9Added Python 3.4, 3.5, 3.7, and multiple branches of pypyPinned requirements' dependency versions.celery 4.1.0 -> 4.2.1kombu 4.1.0 -> 4.2.1billiard 3.5.0 -> 3.5.0.4nose pinned to 1.3.7coverage pinned to 4.3.4 (was already 4.3.4 but fuzzy)codeclimate-test-reported pinned to 0.2.3Extra badge to show the number of downloads (thanks to PePy)0.1.8Fixup for brokenpip install celery_pubsub==0.1.70.1.7PyPI long description fixedRemoved README.md and fixed README.rstAdded commandpython setup.py testto run unit tests with coveragepypy support0.1.5Python 3 support0.1.1Added READMERefined setupNo need to access celery_pubsub.pubsub anymore. Direct access in celery_pubsub.Tests moved out of packageAdded Travis for CI0.1Initial version