Очередь в колбе Python для клона OmeglePython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Очередь в колбе Python для клона Omegle

Сообщение Anonymous »


I've trying to make a queueing system but its not working. The queueing logic im going with is that: Lets say have we have dictionary "queue" which contains the queues. When the dict is empty, we are gonna create a code, add our name to to it, and add all that to the dictionary as an item, and save allat via sessions, AND MOST IMPORTANTLY: Check if the number of members become 2, if in that case, we redirect to /chat. When the dict is not empty, the code we're gonna use is the key of the 1st item in the dict, and save it via sessions, and redirect to /chat

The problem im facing is that the creator of the item in the dictionary, i.e when u click on it when list is empty, THEY DONT REDIRECT. But if ur not the creator of the queue item, instead u click on it when there is already an item (u join, basically), u redirect.

I think the problem lies in the checking of the number of members when an item is created when there are no members, which i wrote under an if statement. Under that if statement is the checking, which i wrote in a While Loop.

CODE:

#on submitting / on post request if len(queue) == 0: code = "".join(random.choices(ascii_uppercase, k=4)) queue

Код: Выделить всё

 = {"members" : [name]}             session["name"] = name             session["favColor"] = favColor             session["code"] = code             while len(queue[code]["members"]) == 1:                 return render_template("waiting.html")             else:                 return redirect(url_for("chat"))                  else:              code = next(iter(queue))             queue[code]["members"].append(name)             session["name"] = name             session["favColor"] = favColor             session["code"] = code             if len(queue[code]["members"]) == 2:                 return redirect(url_for("chat"))   [b]And I just mentioned[/b], the coder under the else statement is working fine "i think", its just the code under the if statement.
 
[b]HELP MY LIFE DEPENDS ON WETHER I MAKE THIS[/b]
 

Источник: [url]https://stackoverflow.com/questions/78092542/queueing-in-python-flask-for-an-omegle-clone[/url]
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • Как текущая очередь, очередь отправки и целевая очередь взаимодействуют друг с другом в GCD?
    Anonymous » » в форуме IOS
    0 Ответы
    103 Просмотры
    Последнее сообщение Anonymous
  • PHP Клонирование объекта при наличии ссылки приводит к разрыву клона
    Гость » » в форуме Php
    0 Ответы
    22 Просмотры
    Последнее сообщение Гость
  • Система привязки изометрической сетки для клона Minecraft в Pygame
    Anonymous » » в форуме Python
    0 Ответы
    18 Просмотры
    Последнее сообщение Anonymous
  • Обработка шаблона PHPWord с клонированием строки блока внутри клона блока
    Anonymous » » в форуме Php
    0 Ответы
    88 Просмотры
    Последнее сообщение Anonymous
  • С чего начать создание клона Spotify с помощью STS?
    Anonymous » » в форуме JAVA
    0 Ответы
    6 Просмотры
    Последнее сообщение Anonymous

Вернуться в «Python»