Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug] ModuleNotFoundError: No module named 'resource'

未关闭 适合新手
#33 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
75/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
python
领域
cli

调研方向

从 issue 中所示的 task_queue.py 里的 resource 导入和 get_memory_mb 函数开始。在 Windows 上运行 uvx agent-task-queue@latest 以复现 ModuleNotFoundError,然后验证命令能够成功启动,并且在没有导入错误的情况下报告进程内存。

由索引模型根据 Issue 内容生成。

描述

bug

Describe the bug
Encountered error while attempting to run agent-task-queue

To Reproduce:
Steps to reproduce the behavior:

  1. Run command $uvx agent-task-queue@latest$
  2. Encountered error
Traceback (most recent call last):
  File "<frozen runpy>", line 203, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\sheld\AppData\Local\uv\cache\archive-v0\d0WBs-76xzVqcxx1\Scripts\agent-task-queue.exe\__main__.py", line 4, in <module>
    from task_queue import main
  File "C:\Users\sheld\AppData\Local\uv\cache\archive-v0\d0WBs-76xzVqcxx1\Lib\site-packages\task_queue.py", line 12, in <module>
    import resource
ModuleNotFoundError: No module named 'resource'

Environment (please complete the following information):

  • OS: Windows 11

Additional Notes
import resource is Linux\MacOS specific.

For cross-compatibility, we could use

import os
import psutil

then change

def get_memory_mb() -> float:
    """Get current process memory usage in MB (RSS - resident set size)."""
    usage = resource.getrusage(resource.RUSAGE_SELF)
    # ru_maxrss is in bytes on Linux, kilobytes on macOS
    if os.uname().sysname == "Darwin":
        return usage.ru_maxrss / (1024 * 1024)  # KB to MB
    return usage.ru_maxrss / 1024  # bytes to MB on Linux

to

def get_memory_mb() -> float:
    """Get current process memory usage in MB (RSS - resident set size)."""
    return psutil.Process(os.getpid()).memory_info().rss / (1024 ** 2)

主要语言
Python
星标
68
派生
7
平均合并
51 分钟
30 天内合并 PR
1

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

block/agent-task-queue 的其他 Issue

查看 block/agent-task-queue 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。