- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
经过几天令人沮丧的运行之后,我需要考虑在 VSCode 中调试 celery 工作进程。这是遵循 Celery 文档中创建消息处理程序的建议流程,而不是从同一应用程序发布/订阅。
celery.py 文件:
from __future__ import absolute_import, unicode_literals
import os
import json
from celery import Celery, bootsteps
from kombu import Consumer, Exchange, Queue
dataFeedQueue = Queue('statistical_forecasting', Exchange('forecasting_event_bus', 'direct', durable=False), 'DataFeedUpdatedIntegrationEvent')
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings.local')
app = Celery('statistical_forecasting')
app.config_from_object('django.conf:settings', namespace='CELERY')
# Not required yet as handler is within this file
#app.autodiscover_tasks()
class DataFeedUpdatedHandler(bootsteps.ConsumerStep):
def get_consumers(self, channel):
return [Consumer(channel, queues=[dataFeedQueue], callbacks=[self.handle_message], accept=['json'])]
def handle_message(self, body, message):
event = json.loads(body)
# removed for brevity, but at present echo's message content with print
message.ack()
app.steps['consumer'].add(DataFeedUpdatedHandler)
我的简短项目结构是:
workspace -
vscode -
- launch.json
config -
__init__.py
settings -
local.py
venv -
celery.exe
statistical_forecasting -
__init__.py
celery.py
farms -
__init__.py
handlers.py # ultimately handler code should live here...
从启用 venv 的终端中,我正在运行 celery -Astatistic_forecastingworker -l info
,它似乎成功地设置和运行了基本消息处理程序。
到目前为止,我在 VSCode 中尝试过在 launch.json
中设置以下配置
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Celery",
"type": "python",
"request": "launch",
"module": "celery",
"console": "integratedTerminal",
//"program": "${workspaceFolder}\\env\\Scripts\\celery.exe",
"args": [
"worker",
"-A statistical_forecasting",
"-l info",
]
},
]
}
不幸的是,这只会导致以下消息:
Error:
Unable to load celery application.
The module statistical_forecasting was not found.
从逻辑上讲,我可以推断调试应该从工作区目录运行celery
,并且它应该看到带有__init__.py的
技术使其成为一个模块?statistical_forecasting
目录。
我尝试了其他各种想法,例如强制 lauch.json
中的 program
设置虚拟环境等,但都返回相同的基本错误消息。
statistical_forecasting 中的 'init.py' 包含标准 Django 设置,我不相信它是必需的,因为 celery 任务是在 Django 外部运行的,而且我不打算发布/接收来自 Django 应用程序。
最佳答案
为了其他尝试这样做的人的利益,这是我将 celery 作为模块进行测试的最小配置
{
"name": "Python: Celery",
"module": "celery",
"console": "integratedTerminal",
"args": [
"worker",
"--app=statistical_forecasting",
"--loglevel=INFO",
],
},
关键要点是参数的格式。原始版本使用的是您通常在从命令行运行时看到的缩短版本,例如在教程中。
通常您会看到celery -Astatistical_forecastingworker -l info
,调试器才能工作,您需要更完整的版本celery --app=statistical_forecastingworker--loglevel=INFO
>.
反射(reflect)下面的评论也可以作为:
{
"name": "Python: Celery",
"module": "celery",
"console": "integratedTerminal",
"args": [
"worker",
"-A",
"statistical_forecasting",
"-l",
"info",
],
},
出于兴趣,较长的版本如下,但这主要只是重复 VsCode 默认设置的内容:
{
"name": "Python: Celery",
"type": "python",
"request": "launch",
"module": "celery",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}\\env\\Scripts\\celery.exe",
"pythonPath": "${config:python.pythonPath}",
"args": [
"worker",
"--app=statistical_forecasting",
"--loglevel=INFO",
],
"env":{
"DJANGO_SETTINGS_MODULE": "config.settings.local",
}
},
关于python - VSCode 调试 Celery Worker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57707031/
要构建我的远程环境,我需要设置几个环境变量(它们在 docker-compose 文件中使用)。这些是在我的 ZSH 环境中设置的,因此从终端运行 docker-compose build 可以按预期
这是vscode在主机中安装vscode-server时的日志 我发现它得到了 vscode-server 提交 ID,如下日志: [13:07:27.334] Using commit id "f8
在 devContainer 实例中安装 LiveShare 扩展时出现错误。 例如使用:https://github.com/microsoft/vscode-remote-try-go/然后将扩展
在 devContainer 实例中安装 LiveShare 扩展时出现错误。 例如使用:https://github.com/microsoft/vscode-remote-try-go/然后将扩展
我尝试在代码中构建和调试扩展。 我从https://github.com/microsoft/vscode-wordcount下载了字数统计的样本. 当我单击 F5 时,未生成 ./out 文件夹,并
你好,我最近从 Atom 切换到 Vs-code,并尝试了一些解释如何在他们的网站上添加语言支持的教程,我知道语言支持应该有着色器 问题是如何为自定义语言添加颜色?当我基本上使用每种语言时,我习惯了自
为了为我的数据科学工作流提供足够的计算能力,我在远程机器上使用 Docker 容器。虽然我可以通过 vscode-remote 连接到我的远程机器,但我无法连接到运行在这台机器上的 Docker 容器
我有一个创建多个 Docker 镜像的项目。我想在 vscode-remote 中为每个图像设置一个 devcontainer,以便我可以为每个图像启动一个容器。 我一次只需要启动并连接到一个容器/图
我认为这是可以通过编辑实现的 keybindings.json .由于我似乎无法找到可用命令的列表,因此通过自动完成我已经做到了这一点: { "key": "SHORTCUT"
gopls 需要在工作区的根目录下有一个模块。 您可以通过将每个模块作为工作区文件夹打开来处理多个模块。 此工作流程的改进即将推出 ( https://github.com/golang/go/iss
我的电脑上已经安装了 vscode。不久前我注意到它现在包含在 anaconda 发行版中。与我已经安装的 vscode 相比,使用 anaconda 附带的 vscode 有什么好处吗? 仅供引用,
我的电脑上已经安装了 vscode。不久前我注意到它现在包含在 anaconda 发行版中。与我已经安装的 vscode 相比,使用 anaconda 附带的 vscode 有什么好处吗? 仅供引用,
我想为 VSCode 编写一个扩展,重用 vscode-python 的重构/重命名功能扩大。这样,当用户执行我的命令时,我的扩展程序将对 .py 文件的变量进行重命名。我不知道 vscode-pyt
环境 vscode 版本 1.19.1 (1.19.1) 鲁博科普 (0.52.1) Darwin mbp 16.7.0 Darwin 内核版本 16.7.0:2017 年 10 月 4 日星期三 0
我在写 Markdown 文本时尝试自动换行:我希望当我输入比 wrap line length 长的行时自动换行设置,由硬 中断(即 newline 字符)。 我已经设定 word wrap至 wo
我想制作一个涉及发布到我的 API 的 VSC 扩展,但是当我将我的 fetch 语法写出以发布到我的服务器时,它不起作用。所以我想也许我需要添加 node-fetch,所以我做了npm i --sa
我有一个 master 分支,它是生产分支,因此我创建了几个其他分支来修复和缺陷。我在这些分支中做了一些更改,所以我在这些分支中提交了很多次。根据政策,我必须为 master 分支中的缺陷创建单个提交
我正在使用 Visual Studio Code Insiders 版本 1.65.0-insider。直到 3 天前,我通过 VPN 从工作笔记本电脑连接到工作中的远程服务器时没有遇到任何问题。我有
在 Windows 上,我必须在打开的每个新终端 session 上运行命令 start-ssh-agent.cmd。我的开发环境是VSCode,每天都会打开十几个新终端。每次打开终端后,我都必须手动
我最近开始使用 VSCode,我真的很喜欢它。我用谷歌搜索了我的问题,并试图找到与 VSCode 相关的任何答案。 考虑我有以下代码: if (a === 'some condition') re
我是一名优秀的程序员,十分优秀!