Похожие чаты

Hey guys, I want to delay sendTwitterVideo without blocking bot.sendVideo?

18 ответов

21 просмотр

const sleep = ms => new Promise((resolve, reject) => setTimeout(resolve, ms))

Misan
const sleep = ms => new Promise((resolve, reject) ...

Because this doesn't reject, I like to write it shorter like this: const sleep = t => new Promise(r => setTimeout(r, t))

Misan
const sleep = ms => new Promise((resolve, reject) ...

I do this exactly, except without reject.

jc-| 23:33 Автор вопроса
jc | 23:33
This blocks bot.sendVideo

do bot.sendVideo first, then sleep, then rest

jc | 23:33
This blocks bot.sendVideo

setTimeout(() => /* action after x seconds */, x * 1000); // action to be performed right now

jc-| 23:33 Автор вопроса
A​kshit
setTimeout(() => /* action after x seconds */, x *...

Yeah, this blocks sendVideo function itself, doesn't it? I am calling sendVideo inside for of loop, and I need to keep uploading to twitter with 1 minute intervals and to telegram without any delay

A​kshit
setTimeout is non blocking afaik

await sleep(..) will stop the function exection though

jc | 23:33
Yeah, this blocks sendVideo function itself, doesn...

i think you should make a queue for videos to be sent to twitter and you use setInterval to periodaclly check if there are any videos in the queue and send one if there is any

jc-| 23:33 Автор вопроса
Artem Starikov
i think you should make a queue for videos to be s...

Can't I have one general queue for twitter as well as telegram?

jc | 23:33
Can't I have one general queue for twitter as well...

if you can send videos to telegram instantly, you shouldn't need a queue for that

jc-| 23:33 Автор вопроса
Artem Starikov
if you can send videos to telegram instantly, you ...

I collect the videos that weren't sent yet and then send them away

jc | 23:33
Yeah, this blocks sendVideo function itself, doesn...

what you probably want here is const twitterQueue = []; setInterval(() => { const video = twitterQueue.shift(); if (video) { sendTwitterVideo(..); } }, 60 * 1000); const sendVideo = async (..) => { // .. twitterQueue.push(..); };

jc-| 23:33 Автор вопроса

Похожие вопросы

Обсуждают сегодня

This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
а через ESC-код ?
Alexey Kulakov
29
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
есть ПО, которое лежит папкой, по сути и не инсталится, а просто запускается. Надо раскидать по машинам в домене. Я так понял, что прям настройками GPO, копировать я смогу тол...
Dmitriy
8
any reference of this implementation?
BitBuddha
29
Чёт не понял, я ж правильной функцией воспользовался чтобы вывести отладочную информацию? но что-то она не ловится
notme
18
Привет)) уже кажется эту тему перемусолили, но вот я так и не понял. Я сейчас сижу на 27дюймов 2к мониторе. На Актуальной макоси, если я куплю 27д 4к монитор: - будет ли изобр...
Vladislav Piskunov
16
Карта сайта