Python 线程类型错误:';模块';对象不可调用
我每隔一段时间运行两个python作业。Python 线程类型错误:';模块';对象不可调用,python,python-3.x,Python,Python 3.x,我每隔一段时间运行两个python作业。 activity\u url\u collector和storage\u data\u collector是与index.py位于同一目录中的.py文件 下面是index.py: import schedule import time import psycopg2 import threading import activity_url_collector import storage_data_collector def main():
activity\u url\u collector
和storage\u data\u collector
是与index.py
位于同一目录中的.py
文件
下面是index.py:
import schedule
import time
import psycopg2
import threading
import activity_url_collector
import storage_data_collector
def main():
def run_threaded(job_func):
job_thread = threading.Thread(target=job_func)
job_thread.start()
schedule.every(3).minutes.do(run_threaded, activity_url_collector)
schedule.every(3).minutes.do(run_threaded, storage_data_collector)
schedule.run_all()
print('Post-Processing-Application is running')
while True:
schedule.run_pending()
time.sleep(1)
if __name__=="__main__":
main()
详细错误:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
TypeError: 'module' object is not callable
这里会出什么问题?谢谢。您正在尝试在线程中运行
活动\u url\u收集器
和存储\u数据\u收集器
查看您的导入,这两个模块(Python文件)都可以由解释器直接运行,但它们不是您案例所需的“可调用的”
您可以在线程中运行函数、方法或任何实现\uuuu调用
的对象。作为解决方案,您可以将main()
函数添加到执行实际工作的模块中,并使用activity\u url\u collector.main
作为线程的目标