Answer the question
In order to leave comments, you need to log in
How to remake a method in Python using threading?
Hello!
Faced some confusion about how to remake a method of an existing class using threading.
Actually, the task is for the method to load some information in the background using a thread.
Here is an example of what is done:
class MyClass(object): # наследуется именно от object
""" some stuff"""
def download(self, url, path):
do_thread = threading.Thread(target=self.__load, args=(url, path))
download_thread.daemon = True
download_thread.start()
def __load(self, url, name):
"""загрузка файлов с помощью requests"""
pass
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question