{"id":36650924,"url":"https://github.com/bibenga/barn-py","last_synced_at":"2026-01-12T10:06:32.408Z","repository":{"id":246703252,"uuid":"817293488","full_name":"bibenga/barn-py","owner":"bibenga","description":"Lightweight scheduler and worker for Django using a database","archived":false,"fork":false,"pushed_at":"2024-07-20T12:03:21.000Z","size":187,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-22T20:26:56.679Z","etag":null,"topics":["database","django","postgresql","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bibenga.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-19T12:08:18.000Z","updated_at":"2024-07-20T12:03:25.000Z","dependencies_parsed_at":"2024-07-19T23:05:18.514Z","dependency_job_id":null,"html_url":"https://github.com/bibenga/barn-py","commit_stats":null,"previous_names":["bibenga/barn-py"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/bibenga/barn-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bibenga%2Fbarn-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bibenga%2Fbarn-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bibenga%2Fbarn-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bibenga%2Fbarn-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bibenga","download_url":"https://codeload.github.com/bibenga/barn-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bibenga%2Fbarn-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28337897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T06:09:07.588Z","status":"ssl_error","status_checked_at":"2026-01-12T06:05:18.301Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","django","postgresql","python"],"created_at":"2026-01-12T10:06:30.870Z","updated_at":"2026-01-12T10:06:32.403Z","avatar_url":"https://github.com/bibenga.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# barn-py\n\nLightweight scheduler and worker for Django using a database as backend.\n\nThe task worker and scheduler use the database as a queue to store and find tasks to process\nand you can forget about using `transaction.on_commit`.\n\n**If you want a billion messages per second, get out of here.**\n\n### Examples\n\n#### Use generic models\n\n```python\nfrom django.http import HttpRequest, HttpResponse\nfrom django.db import transaction\nfrom barn.decorators import task\n\n@transaction.atomic\ndef index(request: HttpRequest) -\u003e HttpResponse:\n    html = \"\u003chtml\u003e\u003cbody\u003eHello\u003c/body\u003e\u003c/html\u003e\"\n    # do something with database\n    dummy.delay(view=\"index\", code=\"12\")\n    return HttpResponse(html)\n\n\n@task\ndef dummy(view: str, code: str) -\u003e str:\n    # task called inside transaction\n    return \"ok\"\n```\n\n#### Use your models (prefered)\n\nYou can specify your own model for schedule and task and this approach is preferred.\n\n```python\nfrom django.db import models\nfrom django.core.mail import send_mail\nfrom barn.models import AbstractTask\n\n\nclass EndOfTrialPeriodTask(AbstractTask):\n    user = models.ForeignKey('auth.User', models.CASCADE)\n\n    def process(self) -\u003e None:\n        # go somewhere and do something...\n        self.user.is_active = False\n        self.user.save()\n        NotifyEndOfTrialPeriodTask.objects.create(user_id=self.user_id)\n\n\nclass NotifyEndOfTrialPeriodTask(AbstractTask):\n    user = models.ForeignKey('auth.User', models.CASCADE)\n\n    def process(self) -\u003e None:\n        if self.user.email:\n            send_mail(\n                \"End of trial period\",\n                f\"Hello {self.user.get_full_name()}. Your trial period has ended.\",\n                \"from@example.com\",\n                [self.user.email],\n                fail_silently=False,\n            )\n\n\nclass EndOfSubscriptionTask(AbstractTask):\n    user = models.ForeignKey('auth.User', models.CASCADE)\n\n    def process(self) -\u003e None:\n        # go somewhere and do something...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbibenga%2Fbarn-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbibenga%2Fbarn-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbibenga%2Fbarn-py/lists"}