Skip to content

Commit

Permalink
Remove funding file, add docker/compose for development project and f…
Browse files Browse the repository at this point in the history
…ix (Koed00#18)

task names in logs
  • Loading branch information
GDay authored Oct 20, 2022
1 parent c59f036 commit 8822e7d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
3 changes: 0 additions & 3 deletions .github/FUNDING.yml

This file was deleted.

8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:3.9

ENV PYTHONUNBUFFERED 1
RUN mkdir -p /app
WORKDIR /app
COPY . .
RUN pip install django blessed django-picklefield

15 changes: 8 additions & 7 deletions django_q/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,13 @@ def monitor(result_queue: Queue, broker: Broker = None):
# signal execution done
post_execute.send(sender="django_q", task=task)
# log the result
info_name = f"{task['name']} ({task['func']})"
info_name = get_func_repr(task['func'])
if task["success"]:
# log success
logger.info(_(f"Processed [{info_name}]"))
logger.info(_(f"Processed {info_name} ({task['name']})"))
else:
# log failure
logger.error(_(f"Failed [{info_name}] - {task['result']}"))
logger.error(_(f"Failed {info_name} ({task['name']}) - {task['result']}"))
logger.info(_(f"{name} stopped monitoring results"))


Expand All @@ -422,8 +422,8 @@ def worker(
task_count += 1
# Get the function from the task
func = task["func"]
func_name = func.__name__ if hasattr(func, "__name__") else str(func)
logger.info(_(f'{proc_name} processing [{task["name"]}({func_name})]'))
func_name = get_func_repr(func)
logger.info(_(f'{proc_name} processing {func_name} ({task["name"]})'))
f = task["func"]
# if it's not an instance try to get it from the string
if not callable(task["func"]):
Expand Down Expand Up @@ -460,12 +460,13 @@ def get_func_repr(func):
# convert func to string
if inspect.isfunction(func):
return f"{func.__module__}.{func.__name__}"
elif inspect.ismethod(func):
elif inspect.ismethod(func) and hasattr(func.__self__, '__name__'):
return (
f"{func.__self__.__module__}."
f"{func.__self__.__name__}.{func.__name__}"
)
return func
else:
return str(func)

def save_task(task, broker: Broker):
"""
Expand Down
11 changes: 11 additions & 0 deletions web-docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3'

services:
web:
restart: always
command: python manage.py runserver 0.0.0.0:8000
ports:
- "127.0.0.1:8000:8000"
build: .
volumes:
- .:/app

0 comments on commit 8822e7d

Please sign in to comment.