Похожие чаты

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

18 ответов

23 просмотра

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 Автор вопроса

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

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

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
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
а через ESC-код ?
Alexey Kulakov
29
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
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
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
Карта сайта