How do I stop file being recopied on tasks with multiple retries?

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
So i have tasks which will tweet every 40 mins going thru the lists of accounts and i do extra repitions for retries.

The template is made to proceed- if accounts temp file doesnt exist- copy and take line. So first thread does that and others wait and then take.

The problem is tho im finding for multiple retries I find for some reason they are recopying the file before the total successes are up. It usualy works wihtout this problem but maybe 30% of the time it happens where it recopies the file before the success count is up.

How to stop that? so it wont recopy the master file to temp while running the current set of threads?
 

Nick

Client
Регистрация
22.07.2014
Сообщения
1 980
Благодарностей
815
Баллы
113
use a global variable as a flag instead of checking file existence
 
  • Спасибо
Реакции: Harambulus

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
Yes but likewise what would be the trigger to tell the global variable that all threads are done.
 

Nick

Client
Регистрация
22.07.2014
Сообщения
1 980
Благодарностей
815
Баллы
113
When a thread starts it can increase a variable by 1, when it stops, it whould decrease it.
So checking its value can tell how many threads are running.

I also saw that there's a way to get thread count using Zenno API in C#, check out auto-generated class documentation or search the forum.
 
  • Спасибо
Реакции: Harambulus

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
I presume with global variables I dont have to worry about binding and two threads using them at once like i do with files? since they are made to be run simultaneously?
 

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
The native global variable for zenno dont seem to work properly. I made it so it initialises then increases by one with each subsequent thread and -1 on completion. But I made anotehr glob var checker so i can look in the poster at where they are at and the global variable never goes above 0. but it does go to minus numbers when the threads are completed.
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 708
Баллы
113

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
Yes I already had that and just used it and is working. Works with c# example not with the global variable options in project maker.
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 708
Баллы
113
maybe cause you have you variable in global variables list. it shouldnt be there.
 

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
I see, Well it went there on its own when i made the process, where should it be?

Doesnt matter now but for future reference.
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 708
Баллы
113
it shouldnt be there in list. delete it.
you check within project if variable exist and if not you create it with action, not in variables list
 

LexxWork

Client
Регистрация
31.10.2013
Сообщения
1 190
Благодарностей
788
Баллы
113
I'm offering you not to use global variables at all. Forget about them. Even if you create global variable during the process (locking the object and other things you have to do) the global variable may give the initial value (e.g. 0, but shoud 1 2 3 5 4...) for all started threads and the same - give all threads the same value(e. g. 0, but should -1, -2, -3) at the and.
instead of that mess simply use the linked list as a stack of threads.
when thread starts - lock the snippet and add to list any data.
when the tread goes to finish - check the length of list and after remove the data if not empty or do any work in case of empty (means this is a last thread).
 

Вложения

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 708
Баллы
113
m offering you not to use global variables at all. Forget about them. Even if you create global variable during the process (locking the object and other things you have to do) the global variable may give the initial value (e.g. 0, but shoud 1 2 3 5 4...) for all started threads and the same - give all threads the same value(e. g. 0, but should -1, -2, -3) at the and.
That's not true if you do everything right.
 

LexxWork

Client
Регистрация
31.10.2013
Сообщения
1 190
Благодарностей
788
Баллы
113
i propose the easyest, fastest, extensible and very stable way for share data between threads. I know that i'm right because I've been making the tests. A lot of people hate the global variables and asking me for help them to solve that problem, and i do.
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 708
Баллы
113
Another solution doesnt mean that others dont work. If they dont work, create thread in Bug section and attach example
 

LexxWork

Client
Регистрация
31.10.2013
Сообщения
1 190
Благодарностей
788
Баллы
113
in this case the "others" is just my example project ) and it works wery well
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 708
Баллы
113
the only thing that i tried to explain is that anything is not working like it should - you create thread in Bug section with example.
 

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
it shouldnt be there in list. delete it.
you check within project if variable exist and if not you create it with action, not in variables list
Im having this problem agian but now with the c# version as well. I copy and pasted it from the other project and notice the thread active is 'declared within project' whereas in the original one which works it is declared outside project.

I tried to click the little arrow at the side to delete it like i would delete variables usually but i cant so how do i get rid of it? or solve this issue?

Its doing exactly the same thing that my OP was about- not adding values yet still deleting on failure producing -1, -2, -3 etc.

Its ok i see tehre is a remove button above. This seems to be a problem then that it defaults to add inside the project sometimes. I know to look out for it now but others will run into problems so I guess you should look at it for future builds.
 
Последнее редактирование:

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 708
Баллы
113
Task was set :-)
 

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
Still not working correctly.

It still copies the files over sometimes before run is complete.

Im thinking maybe its because if there are 3 threads running for example and counter is on 3, if they all complete at a similar time then the counter would return to 0 and thus copy the file over again. So how can I workaround that while sitll returning to 0 at end of run? because i cant add extras counts without it ending up more than 0 at end of run.
 

rostonix

Известная личность
Регистрация
23.12.2011
Сообщения
29 067
Благодарностей
5 708
Баллы
113
Check logic of your project. I don't know how it organized and what it should do and when
 

LexxWork

Client
Регистрация
31.10.2013
Сообщения
1 190
Благодарностей
788
Баллы
113

Вложения

  • Спасибо
Реакции: Harambulus

Harambulus

Client
Регистрация
16.09.2011
Сообщения
365
Благодарностей
10
Баллы
18
Thanks thats pretty much exactly what i do currently. Though my thread count logic check is at the start rather than the end, yet still having issues. I guess i have to keep analysing with a toothcomb till i figure it out.
 

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