Skip to content

Commit e1929b8

Browse files
committed
dump_request
1 parent f95da88 commit e1929b8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

codeforlife/servers/celery.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
class CeleryServer(BaseServer, Celery):
2121
"""A server for a Celery app."""
2222

23-
def __init__(self, auto_run: bool = True):
23+
def __init__(self, auto_run: bool = True, dump_request: bool = False):
24+
# pylint: disable=line-too-long
2425
"""Initialize a Celery app.
2526
2627
Examples:
@@ -35,10 +36,12 @@ def __init__(self, auto_run: bool = True):
3536
3637
Args:
3738
auto_run: A flag designating whether to auto-run the server.
39+
dump_request: A flag designating whether to add the dump_request task (useful for debugging).
3840
3941
Raises:
4042
EnvironmentError: If "DJANGO_SETTINGS_MODULE" is not in os.environ.
4143
"""
44+
# pylint: enable=line-too-long
4245

4346
call_django_command("check")
4447

@@ -58,14 +61,14 @@ def __init__(self, auto_run: bool = True):
5861
# Load task modules from all registered Django apps.
5962
self.autodiscover_tasks()
6063

61-
if self.django_dev_server_is_running():
64+
if dump_request:
6265

6366
@self.task(
6467
name=f"{settings.SERVICE_NAME}.dump_request",
6568
bind=True,
6669
ignore_result=True,
6770
)
68-
def dump_request(self, *args, **kwargs):
71+
def _dump_request(self, *args, **kwargs):
6972
"""Dumps its own request information."""
7073

7174
logging.info("Request: %s", self.request)

0 commit comments

Comments
 (0)