TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Chard – simple async/await background tasks for Django

61 点作者 drpancake超过 2 年前

4 条评论

drpancake超过 2 年前
Hey everyone. The idea here is take advantage of the new async&#x2F;await ORM features in Django 4.1* to build a lightweight background task queue for Django that runs in a single worker process without any external dependencies (i.e. no Redis&#x2F;RabbitMQ).<p>It&#x27;s pretty basic and experimental. Feedback and PRs welcome!<p>*The Django ORM is still using sync-to-async compatibility layer behind the scenes but they plan to phase this out in future versions.
评论 #32801454 未加载
评论 #32802867 未加载
评论 #32800168 未加载
评论 #32800686 未加载
lmeyerov超过 2 年前
Awesome, we were just discussing internally how to do such an architecture<p>Maybe a &quot;where to help&quot; &#x2F; roadmap section for a sense of &#x27;what is left for a stable &amp; reasonably complete 1.0 api&#x27;?
评论 #32805732 未加载
spapas82超过 2 年前
My problem with this (and similar projects) is that there actually <i>is</i> a dependency: Running the worker!<p>This may look like a small thing but in a production environment this means that instead of running 1 thing for your django app (a gunicorn or uwsgi app server) you need to add another thing (the worker). This results to<p>* Monitoring the worker (getting alerts when the worker stops, make sure it runs etc) * Start the worker when your server starts * Re-start the worker when you deploy changes (this is critical and easily missed; your worker won&#x27;t pick any changes to your app whne you deploy it, if you don&#x27;t re-start it it will run stale code) * Make sure you have some kind of logging and exception tracking for the worker<p>All this adds up especially if you need to do it all the time for new apps.<p>So, my ideal async task thingie would be to start an async worker <i>on the fly</i> when there are tasks; the worker will be killed when the task has finished (or stay alive some time to pick any new tasks, whatever). So no plumbing of running a worker indenepdently.<p>My understanding is that although this is trivial in languages like Java, C# or Elixir (and even C), it ain&#x27;t really possible in python because of how python works!<p>Also, if I am not mistaken, the whole async functionality that python has added and django tries to include does not help on this, i.e even if you use all the async features on django and python you can&#x27;t do something like create and run an async job without running an extra process (a worker) along with the plumbing that goes with that!<p>Or I am mistaken? I&#x27;d really like to be mistaken on that :)
评论 #32800930 未加载
etaioinshrdlu超过 2 年前
It looks like it requires all the code in your task to use async code?
评论 #32805696 未加载