Skip to content

Commit f95da88

Browse files
committed
tidy up
1 parent 7764242 commit f95da88

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

codeforlife/servers/celery.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77

88
import atexit
9-
import os
9+
import logging
1010
import subprocess
1111
import typing as t
1212

@@ -20,11 +20,7 @@
2020
class CeleryServer(BaseServer, Celery):
2121
"""A server for a Celery app."""
2222

23-
def __init__(
24-
self,
25-
auto_run: bool = True,
26-
debug: bool = bool(int(os.getenv("DEBUG", "1"))),
27-
):
23+
def __init__(self, auto_run: bool = True):
2824
"""Initialize a Celery app.
2925
3026
Examples:
@@ -39,7 +35,6 @@ def __init__(
3935
4036
Args:
4137
auto_run: A flag designating whether to auto-run the server.
42-
debug: A flag designating whether to run the app in debug mode.
4338
4439
Raises:
4540
EnvironmentError: If "DJANGO_SETTINGS_MODULE" is not in os.environ.
@@ -63,17 +58,17 @@ def __init__(
6358
# Load task modules from all registered Django apps.
6459
self.autodiscover_tasks()
6560

66-
if debug:
61+
if self.django_dev_server_is_running():
6762

6863
@self.task(
69-
name=f"{settings.SERVICE_NAME}.debug",
64+
name=f"{settings.SERVICE_NAME}.dump_request",
7065
bind=True,
7166
ignore_result=True,
7267
)
73-
def _debug(self, *args, **kwargs):
68+
def dump_request(self, *args, **kwargs):
7469
"""Dumps its own request information."""
7570

76-
print(f"Request: {self.request!r}")
71+
logging.info("Request: %s", self.request)
7772

7873
if auto_run and (
7974
self.app_server_is_running() or self.django_dev_server_is_running()

0 commit comments

Comments
 (0)