使用threadpoolexecutor进行python动态执行

时间:2018-02-19 15:51:51

标签: python threadpoolexecutor

我正在动态加载模块并尝试执行它们包含的类:

Cookie: PHPSESSID=t3t7efdk9ljpt1vrn62rmv2647 

但是在执行时我收到错误:

(SELECT COUNT (CCID) FROM validCC WHERE sgs.STUDENTSDCID = validCC.STUDENTSDCID and sgs.SECTIONSDCID = validCC.SECTIONID) as CC_OK,
(SELECT COUNT (SECTIONID) FROM validCrsSect WHERE sgs.SECTIONSDCID = validCrsSect.SECTIONSDCID) AS CRS_OK,
(SELECT COUNT (STANDARDID) FROM validStandard WHERE sgs.STANDARDID = validStandard.STANDARDID) AS STD_OK

1 个答案:

答案 0 :(得分:1)

我会看看instance对象,我认为它可能只是type / class对象而不是Test对象......你是试图在没有实例化对象的情况下调用该方法

所以你应该实例化"实例"

instance = getattr(importlib.import_module(services_path + '.' + s), s.title())()

或尝试类似

的内容
# keep "instance" as is
instance = getattr(importlib.import_module(services_path + '.' + s), s.title())
# and
def _instance_start(instance_class):
    return instance_class().start
executor.submit(_instance_start(instance))