В настоящее время я изучаю Python и Classes, и у меня есть основной вопрос, но я не нашел ответа на него. Скажем, у меня есть этот фиктивный класс
class DomainOperations:
def __init__(self, domain):
self.domain = domain
self.domain_ip = ''
self.website_thumbnail = ''
def resolve_domain(self):
#resolve domain to ipv4 and save to self.domain_ip
def generate_website_thumbnail(self):
#generate website thumbnail and save the url to self.website_thumbnail
Я хочу запускать одновременно resol_domain и generate_website_thumbnail, а когда потоки закончены, я хочу напечатать IP и миниатюру.
EDIT: Я знаю, что должен использовать потоки, может быть, что-то вроде этого
r = DomainOperations('google.com')
t1 = threading.Thread(target=r.resolve_domain)
t1.start()
t2 = threading.Thread(target=r.generate_website_thumbnail)
t2.start()
Но следует ли использовать их вне класса? Должен ли я писать другой класс для обработки потоков?
Что такое правильный путь?