Django同步函数:等待一个会话以使用函数完成

发布于 2025-01-21 13:56:36 字数 208 浏览 1 评论 0原文

在我的Django服务器中,我具有一个可以处理用户请求的函数。当多个用户同时从各自的会话中发送请求时,该函数会在其自己的会话中处理请求,因此并行进行。但是我想确保当我有多个用户的多个请求时,他们会被一个一个一个而不是同时处理。基本上,我不希望此功能是会话实例,而是一个只有一个用户一次可以使用的全局函数。我该如何解决这个问题?这是一个开放式的问题,只要我们在实施中使用Django,我就没有更多的约束。

In my django server, I have a function that handles a request from a user. When multiple users are sending requests from within their respective sessions at the same time, the function processes the requests within their own sessions so it happens in parallel. But I want to ensure that when I have multiple requests from multiple users, they are handled one by one rather than simultaneously. Basically, I don't want this function to be a session instance but a global function that only one user can use at a time. How can I solve this problem? This is an open-ended question so as long as we are using Django in the implementation I don't have any more constraints.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文