Py学习  »  Python

Python线程子线程:未调用

Max • 5 年前 • 1526 次点击  

我目前正在尝试编写自己的子类 threading.Thread . 然而,似乎 __init__ AttributeError run 当我想用 self.x

这是我的代码:

class MonitoringWorker(threading.Thread):
    def __int__(self, threads_hashtag: int = 1, threads_image: int = 4, threads_user: int = 1):
        self.threads_hashtag = threads_hashtag
        self.threads_image = threads_image
        self.threads_user = threads_user

        self.queue_hashtag = Queue()
        self.queue_image_meta_first = Queue()
        self.queue_image_meta_second = Queue()
        self.queue_image_meta_third = Queue()
        self.queue_user = Queue()
        super().__init__()

    def run(self):
        workers_hashtag = [HashtagWorker(self.queue_hashtag, self.queue_image_meta_first, i) for i in range(self.threads_hashtag)]
        # do stuff


if __name__ == '__main__':
    m = MonitoringWorker()
    m.start()
    m.join()

有人能解释这种行为吗?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/54328
 
1526 次点击  
文章 [ 1 ]  |  最新文章 5 年前
Venkatesh-Prasad Ranganath
Reply   •   1 楼
Venkatesh-Prasad Ranganath    5 年前

你有个错别字 __init__ 而不是 __int__