K
K
Kalachick2022-03-20 14:19:50
Python
Kalachick, 2022-03-20 14:19:50

How to run the same script in different threads?

You need to run the same script in different threads, but in each of them you will need to change the data in the variable

class Farm:
    def __init__(self):
        self.main = durakonline.Client(MAIN_TOKEN, server_id=SERVER_ID, tag="[MAIN]", debug=DEBUG_MODE)
        self.bot = durakonline.Client(tag="[BOT]", server_id=SERVER_ID, debug=DEBUG_MODE)
В переменной SERVER_ID должны менятся данные от того какой поток.
Пытался сделать с args не получилось.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GroMan_L, 2022-03-21
@GroMan_L

from threading import Thread
class Farm:
    def __init__(self, SERVER_ID, DEBUG_MODE):
        self.main = durakonline.Client(MAIN_TOKEN, server_id=SERVER_ID, tag="[MAIN]", debug=DEBUG_MODE)
        self.bot = durakonline.Client(tag="[BOT]", server_id=SERVER_ID, debug=DEBUG_MODE)

thread1 = Thread(target= Farm, args = 'значение SERVER_ID', 'значение DEBUG_MODE')
thread2 = Thread(target= Farm, args = 'значение SERVER_ID', 'значение DEBUG_MODE')

thread1.start()
thread2.start()

Should work
Or you can make a function from a class

K
Kalachick, 2022-03-21
@Kalachick

Well, that's not the whole script.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question