Skip to content

Commit

Permalink
Improving celery compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
emher committed Sep 10, 2022
1 parent a4dcb31 commit bd7827b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.

- Reimplementation of the `BeforeAfter` component by @AnnMarieW adding new features and improved mobile compatibility. NB: This is a **breaking** change, please consult the docs for an example using the new syntax
- Improved support for the new `callback(background=True, ...)` syntax adding support for the `set_progress` keyword
- Added syntax sugar for Celery task registration for use with the `CeleryManager` object
- Added explicit raise of `NotImplementedError` for the (deprecated) `long_callback` syntax

## [0.1.5] - 17-07-22
Expand Down
11 changes: 9 additions & 2 deletions dash_extensions/enrich.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging
import secrets
import struct
import sys
import uuid
import plotly
import dash
Expand Down Expand Up @@ -352,9 +353,15 @@ def long_callback(self, *_args, **_kwargs):
raise NotImplementedError(
"The 'long_callback(..)' syntax is not supported, please use 'callback(background=True, ...)' instead.")

def _setup_server(self):
# Register the callbacks.
def register_celery_tasks(self):
if sys.argv[0].endswith("celery"):
self.register_callbacks()

def register_callbacks(self):
self.blueprint.register_callbacks(super())

def _setup_server(self):
self.register_callbacks()
# Proceed as normally.
super()._setup_server()
# Remap callback bindings to enable callback registration via the 'before_first_request' hook.
Expand Down

0 comments on commit bd7827b

Please sign in to comment.