Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how i cat kill the execution in queue of an async task if timeout and start next? #1542

Open
Citramones opened this issue Jun 30, 2023 · 0 comments

Comments

@Citramones
Copy link

Using Agenda for job queue, please advise how to stop the execution of an async task if timeout is reached and delete it from the database Let's say we have a code example :
agenda.define('processMessage', { concurrency: 1 }, async (task, done) => {
try {
const { contexts } = task.attrs.data;
const message_id = contexts.callbackQuery.message.reply_to_message.message_id;
const id = contexts.callbackQuery.message.reply_to_message.from.id;

    await bot.telegram.sendChatAction(id, 'record_audio');
    await textToSpeech(contexts.callbackQuery.message.reply_to_message.text, id, message_id);
    await waitForFile("{__dirname}/tmp/", ${id}_${message_id}.wav);
    await convertTo(${__dirname}/tmp/${id}_${message_id}.wav, {__dirname}/tmp/${id}_${message_id}_${username}.out.ogg);
    await bot.telegram.sendVoice(id, { source: {__dirname}/tmp/${id}_${message_id}.out.ogg }, { reply_to_message_id: message_id, allow_sending_without_reply: true }).then(() => {
        console.log('+');
    })
        .catch((error) => {
            console.error('Eror send qeueu:', error);
        });;
} catch (error) {
    console.error(error);
}

await task.remove();

});

At what point should I check for exceeding the time limit for this task? I can't know exactly at which point it stops the process.😰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant