嗨,我有一个Django项目。在我的项目中,我希望对所有传入的post请求进行排队,并显示序列号。先入先出。我该怎么做呢?因为我已经创建了一个可以让许多人同时提交请求的项目。当我同时收到这样的请求时,服务器可能会崩溃或延迟可能会occur.For这个,我想过排队并给用户提供序列号,但我找不到太多的来源。例如,突然来了10个请求,服务器在后台调用函数,出现序列号10。然后发出第一个请求的用户得到响应,序列号降为9。
发布于 2021-07-09 06:20:30
queue = []
# Adding elements to the queue
queue.append('1')
queue.append('2')
queue.append('3')
print("Initial queue")
print(queue)
# Removing elements from the queue
print("\nElements dequeued from queue")
print(queue.pop(0))
print(queue.pop(0))
print(queue.pop(0))
print("\nQueue after removing elements")
print(queue)
And then just add a user ID sectionhttps://stackoverflow.com/questions/68309162
复制相似问题