首页 新闻 会员 周边 捐助

Vscode 调试的时候报错

0
[已解决问题] 解决于 2021-11-24 15:22

我只是引用了 apscheduler 他就不能调试了

  File "f:\project\Python\Ven\lib\site-packages\apscheduler\schedulers\asyncio.py", line 48, in _configure
    super(AsyncIOScheduler, self)._configure(config)
  File "f:\project\Python\Ven\lib\site-packages\apscheduler\schedulers\base.py", line 717, in _configure
    executor = self._create_plugin_instance('executor', plugin, value)
  File "f:\project\Python\Ven\lib\site-packages\apscheduler\schedulers\base.py", line 904, in _create_plugin_instance
    raise LookupError('No {0} by the name "{1}" was found'.format(type_, alias))
LookupError: No executor by the name "threadpool" was found

请问 vscode 不支持线程调试吗?

我直接启动程序是可以的

永远跟党走i的主页 永远跟党走i | 小虾三级 | 园豆:1542
提问于:2021-11-24 10:38
< >
分享
最佳答案
0

支持的不过要用他自己的,他内部也有这个包的名称

from apscheduler.executors.pool import ThreadPoolExecutor

executors = {
    'default': ThreadPoolExecutor(20) 
}
scheduler = BackgroundScheduler(executors=executors)
奖励园豆:5
小小咸鱼YwY | 老鸟四级 |园豆:3312 | 2021-11-24 11:37

大佬,按你的弄,又 出现这个问题了

ERROR:    Traceback (most recent call last):
  File "f:\project\Python\Ven\lib\site-packages\apscheduler\schedulers\base.py", line 896, in _create_plugin_instance
    plugin_cls = class_container[alias]
KeyError: 'date'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "f:\project\Python\Ven\lib\site-packages\starlette\routing.py", line 621, in lifespan
    async with self.lifespan_context(app):
  File "f:\project\Python\Ven\lib\site-packages\starlette\routing.py", line 518, in __aenter__
    await self._router.startup()
  File "f:\project\Python\Ven\lib\site-packages\starlette\routing.py", line 598, in startup
    await handler()
  File "f:\project\Python\dianda\FreightsmartAPI\Model\scheduler\tasks.py", line 16, in init_scheduler
    scheduler.add_job(func=init_echo, trigger="date", next_run_time=datetime.now())
  File "f:\project\Python\Ven\lib\site-packages\apscheduler\schedulers\base.py", line 420, in add_job
    'trigger': self._create_trigger(trigger, trigger_args),
  File "f:\project\Python\Ven\lib\site-packages\apscheduler\schedulers\base.py", line 921, in _create_trigger
    return self._create_plugin_instance('trigger', trigger, trigger_args)
  File "f:\project\Python\Ven\lib\site-packages\apscheduler\schedulers\base.py", line 904, in _create_plugin_instance
    raise LookupError('No {0} by the name "{1}" was found'.format(type_, alias))
LookupError: No trigger by the name "date" was found

永远跟党走i | 园豆:1542 (小虾三级) | 2021-11-24 15:20

nb

我找到问题了

async def init_scheduler():
    scheduler.configure(**settings.dict())
    print("---------初始化 scheduler --------")
    # schedule test
    # scheduler.add_job(func=init_echo, trigger="date", next_run_time=datetime.now())
    scheduler.start()


# def init_echo():
#     print("---------测试启动任务------ ")


请问一下,这里为什么写了data就出现上门这个问题呢?

永远跟党走i | 园豆:1542 (小虾三级) | 2021-11-24 15:22

运行的代码片段看看

小小咸鱼YwY | 园豆:3312 (老鸟四级) | 2021-11-24 15:26

你看下官方文档就很清楚了

func – callable (or a textual reference to one) to run at the given time

trigger (str|apscheduler.triggers.base.BaseTrigger) – trigger that determines when func is called

args (list|tuple) – list of positional arguments to call func with

kwargs (dict) – dict of keyword arguments to call func with

id (str|unicode) – explicit identifier for the job (for modifying it later)

name (str|unicode) – textual description of the job

misfire_grace_time (int) – seconds after the designated runtime that the job is still allowed to be run (or None to allow the job to run no matter how late it is)

coalesce (bool) – run once instead of many times if the scheduler determines that the job should be run more than once in succession

max_instances (int) – maximum number of concurrently running instances allowed for this job

next_run_time (datetime) – when to first run the job, regardless of the trigger (pass None to add the job as paused)

jobstore (str|unicode) – alias of the job store to store the job in

executor (str|unicode) – alias of the executor to run the job with

replace_existing (bool) – True to replace an existing job with the same id (but retain the number of runs from the existing one)

小小咸鱼YwY | 园豆:3312 (老鸟四级) | 2021-11-24 15:31

@小小咸鱼YwY: trigger有date, interval, cron可供选择,其实看字面意思也可以知道,date表示具体的一次性任务,interval表示循环任务,cron表示定时任务,我都一次性了你告诉我运行时间是现在,你为什么不直接init_echo(),而且datetime.now()获取的这一刻肯能已经过了

小小咸鱼YwY | 园豆:3312 (老鸟四级) | 2021-11-24 15:36
其他回答(1)
0

你用 rpdb 试试, 有些场景没法在主线程调试

〆灬丶 | 园豆:2314 (老鸟四级) | 2021-11-24 10:53

谢谢

支持(0) 反对(0) 永远跟党走i | 园豆:1542 (小虾三级) | 2021-11-24 15:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册