Run multiple threads, and the first one to open the site makes all the others stop running. Help

cesario678

Client
Регистрация
10.03.2022
Сообщения
171
Благодарностей
12
Баллы
18
Is there a way to run the bot with multiple threads, like around 20 threads, and when the thread that enters the site first, it locks all the other threads so that only the one that opened the site first can be used?
 

zactyson64

Client
Регистрация
18.03.2019
Сообщения
43
Благодарностей
3
Баллы
8
you can write some line in a file and check if the line is there, if it's there then pause, one of the threads will be the fastest to write the line and all other threads will see the line already there so they won't continue
 
  • Спасибо
Реакции: cesario678

myndeswx

Client
Регистрация
15.05.2017
Сообщения
436
Благодарностей
104
Баллы
43
Seems like a job for 'global variables', you could create a variable 'inuse', it's value will be shared across different threads.
Default value should be False
Before entering the page each thread must check if that global variable 'inuse' = false , if it is true- then wait 10s and check again.
When inuse = false - thread can enter the page, and set inuse= true, so other threads must wait, hope it makes sense.

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

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