Implementing a Background Global Task in a ZennoPoster Script

Ottocomm

Новичок
Регистрация
10.02.2024
Сообщения
4
Благодарностей
0
Баллы
1
Hello everyone,
I'm currently working on a project using ZennoPoster and I've encountered a specific issue. I'm looking to find out if it's possible to set up a task that runs in the background throughout the execution of my script. The idea is to have some sort of "global" condition or action that automatically applies, no matter where in the script execution I am.
To illustrate my need, here are two examples:
  1. Automatic Redirection: If, at any point, the script navigates to a specific page (for example, Google.com), it should automatically redirect to another page (Bing.com), without me needing to insert this condition at every step of my script.
  2. Error Handling: If the message "Cannot reach this page" appears on the screen, the script should either restart from the beginning or execute a predefined action, automatically, without me having to configure this response for every action in my script.
My goal is to simplify my script by avoiding the repetition of these conditions or actions at every step. Does ZennoPoster allow for setting up this kind of "global" task that remains valid and active in the background for the duration of the script execution, no matter the different pages or stages reached?
I appreciate any advice or solutions you can provide. I hope I have made my request clear. If you need any clarification, please don't hesitate to let me know.

Thanks
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 812
Благодарностей
1 187
Баллы
113
Hi, Wellcome to the forum. @Ottocomm ;-)
Unfortunatelly,there is no such global tasks in programming since each of them requires different logic they can't be merged as one. Makes little sense. For each case, you can find a solution. For this redirect thing, you can edit your windows hosts file and it will redirect you automatically if going to url x it will redirect to url y.

Second case, need to look closer, but you have to build your templates in such a way that they can fail whatever, and you should save this fail state and then next thread loads same state and continue from failed place. What state means depends on task to task.
 

Ottocomm

Новичок
Регистрация
10.02.2024
Сообщения
4
Благодарностей
0
Баллы
1
Thank you for your response, @lokiys :-).
Regarding the first case, I will indeed look into the Windows solution, although my initial intent was to handle it within ZennoPoster and not on my entire PC. However, I will seek an external workaround for this.

For the second case, I would appreciate further elaboration. I'm not entirely clear on how to implement a system where tasks fail in such a way that the next thread can remember this and avoid making the same mistake. Could you please provide more details on this?

Is it possible to configure a task so that if there's no activity on a tab for more than a certain amount of time, even though the thread is still running, it could either be marked as BAD or the session could be terminated? I encounter issues like blank instances or "This site can't be reached" errors, likely due to proxy errors, etc. When this happens, nothing progresses for a certain duration, and I would like the thread to close and restart, for example. I've tried using the tab settings, but it didn't make a difference, and I've also attempted to use the browser settings to restart an instance. This was partly to manage instances restarting after running for a while to prevent excessive memory usage.

Thanks
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 812
Благодарностей
1 187
Баллы
113
Unfortunately, I can not possibly give you more details about saving state, as this varies from task to task. And I did not mean that threads learn from each other. In short, what i mean is. Example: You have a template with 3 pages. You fill forms on the first page and then you go to the second page. If some error happens on the second page, save all data that you entered the first page and also save that you failed on the second page. Then complete this thread with error and close it and save the state. Then next thread comes pick up the saved state and continue to work from the second page.
 

Ottocomm

Новичок
Регистрация
10.02.2024
Сообщения
4
Благодарностей
0
Баллы
1
Thank you, @lokiys, for clarifying the approach regarding saving the state. I will look into this and see what I can do.

Regarding the second part of my message, do you have any advice?

"Is it possible to configure a task so that if there's no activity on a tab for more than a certain amount of time, even though the thread is still running, it could either be marked as BAD or the session could be terminated? I encounter issues like blank instances or 'This site can't be reached' errors, likely due to proxy errors, etc. When this happens, nothing progresses for a certain duration, and I would like the thread to close and restart, for example. I've tried using the tab settings, but it didn't make a difference, and I've also attempted to use the browser settings to restart an instance. This was partly to manage instances restarting after running for a while to prevent excessive memory usage."


Thanks
 

lokiys

Moderator
Регистрация
01.02.2012
Сообщения
4 812
Благодарностей
1 187
Баллы
113
Thank you, @lokiys, for clarifying the approach regarding saving the state. I will look into this and see what I can do.

Regarding the second part of my message, do you have any advice?

"Is it possible to configure a task so that if there's no activity on a tab for more than a certain amount of time, even though the thread is still running, it could either be marked as BAD or the session could be terminated? I encounter issues like blank instances or 'This site can't be reached' errors, likely due to proxy errors, etc. When this happens, nothing progresses for a certain duration, and I would like the thread to close and restart, for example. I've tried using the tab settings, but it didn't make a difference, and I've also attempted to use the browser settings to restart an instance. This was partly to manage instances restarting after running for a while to prevent excessive memory usage."

Thanks
117733


This sounds similar you are looking for, I guess.
Set execution timeout x seconds and if any threads will hang, it will be closed down after your configured x seconds.
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)