python多线程并且发回结果

import threading


class MyThread(threading.Thread):
    def __init__(self, func, args):
        super(MyThread, self).__init__()
        self.func = func
        self.args = args

    def run(self):
        self.result = self.func(*self.args)

    def get_result(self):
        try:
            return self.result
        except Exception:
            return None

 

posted @ 2021-01-18 10:04  Tarzen  阅读(109)  评论(0编辑  收藏  举报