This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from celery import Task | |
| from celery.task import task | |
| from my_app.models import FailedTask | |
| from django.db import models | |
| @task(base=LogErrorsTask) | |
| def some task(): | |
| return result | |
| class LogErrorsTask(Task): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| from rest_framework import serializers, renderers, parsers | |
| class JSONRenderer(renderers.JSONRenderer): | |
| def render(self, data, *args, **kwargs): | |
| if data: | |
| data = recursive_key_map(underscore_to_camelcase, data) | |
| return super(JSONRenderer, self).render(data, *args, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import timedelta | |
| def week_range(date): | |
| """Find the first & last day of the week for the given day. | |
| Assuming weeks start on Sunday and end on Saturday. | |
| Returns a tuple of ``(start_date, end_date)``. | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # nuke the queue | |
| redis-cli FLUSHALL | |
| # nuke anything currently running | |
| pkill -9 celeryd | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> import base64 | |
| >>> import hashlib | |
| >>> base64.b64encode(hashlib.sha1("test").digest()) | |
| 'qUqP5cyxm6YcTAhz05Hph5gvu9M=' |
NewerOlder