manbytesgnu_site

Source files for manbytesgnu.org
git clone git://holbrook.no/manbytesgnu_site.git
Log | Files | Refs

20210425_celery_document_graph.rst (879B)


      1 Documenting Celery task chains
      2 ##############################
      3 
      4 :date: 2021-04-25 15:00
      5 :modified: 2021-04-25 15:00
      6 :category: Code
      7 :author: Louis Holbrook
      8 :tags: python,microservices,celery
      9 :slug: celery-document-graph
     10 :summary: How do document complex task chains in Python Celery using graphviz
     11 :lang: en
     12 :status: draft
     13 
     14 .. code-block:: python
     15 
     16         current_app.conf.update({
     17         'broker_url': broker,
     18         })
     19 
     20         result = config.get('CELERY_RESULT_URL')
     21         if result[:4] == 'file':
     22             rq = tempfile.mkdtemp()
     23             current_app.conf.update({
     24                 'result_backend': 'file://{}'.format(rq),
     25                 })
     26             logg.warning('celery backend store dir {} created, will NOT be deleted on shutdown'.format(rq))
     27         else:
     28             current_app.conf.update({
     29                 'result_backend': result,
     30                 })
     31 
     32