diff --git a/back/tgbot/apps.py b/back/tgbot/apps.py index 746f0de..e190ee7 100644 --- a/back/tgbot/apps.py +++ b/back/tgbot/apps.py @@ -10,7 +10,7 @@ class TgBotUpdater: tgbot_class = None my_queue = queue.Queue() - return_queue = queue.Queue() + return_values = dict() import logging diff --git a/back/tgbot/tgbot.py b/back/tgbot/tgbot.py index ffe83ab..b4dbda0 100644 --- a/back/tgbot/tgbot.py +++ b/back/tgbot/tgbot.py @@ -67,7 +67,7 @@ class TgBot: async for item in queryset: try: text = await TgBot.app.bot.get_file(item.text) - TgBotUpdater.return_queue.put(text.file_path) + TgBotUpdater.return_values[item.text] = text.file_path except Exception as e: pass diff --git a/back/tgbot/views.py b/back/tgbot/views.py index fdafdab..c1560a9 100644 --- a/back/tgbot/views.py +++ b/back/tgbot/views.py @@ -43,13 +43,14 @@ class TmcFieldViewset(viewsets.ModelViewSet): field = TmcField.objects.filter(id=field_id) TgBotUpdater.my_queue.put({"name": "admin_get_image", "queryset": field}) response = [] - timer = 3 + timer = 30 while timer > 0: sleeping = 1 timer -= sleeping time.sleep(sleeping) - if not TgBotUpdater.return_queue.empty(): - response.append(TgBotUpdater.return_queue.get()) + if field[0].text in TgBotUpdater.return_values: + response.append(TgBotUpdater.return_values[field[0].text]) + del TgBotUpdater.return_values[field[0].text] break return Response(response) else: diff --git a/front/components/getImage.vue b/front/components/getImage.vue index 5e05ec1..a278396 100644 --- a/front/components/getImage.vue +++ b/front/components/getImage.vue @@ -16,11 +16,13 @@ const openImage = () => { isOpen.value = !isOpen.value } -