labthings / labthings/python-labthings

Changing `ActionView._deque.maxlen` in subclasses

未关闭
#300 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
19
派生
2
PR 合并指标
30 天内没有已合并 PR

描述

Is your feature request related to a problem? Please describe.
I tried to lower the length of the ActionView _deque but could not find a way that would not result in a bug

Describe the solution you'd like

I would like to have a method to specify the ActionView queue length, ideally at the subclass definition level.

Describe alternatives you've considered
I tried:

  1. Changing the class attribute
class MyAction(ActionView):
    args = {
        "averages": fields.Integer(
            missing=20,
            example=20,
            description="Number of images to average over",
        )
    }
    # Marshal the response as a string representation of the array
    schema = fields.String()
    _deque = Deque(maxlen=10)
    ...

I believe this is rendered useless by the __init_subclass__ method.

  1. Overwritting the _deque at init:
class MyAction(ActionView):
    args = {
        "averages": fields.Integer(
            missing=20,
            example=20,
            description="Number of images to average over",
        )
    }
    # Marshal the response as a string representation of the array
    schema = fields.String()
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._deque = Deque(maxlen=10)
    ...

This solution is causing the request to hang.

I also tried subclassing __init_subclass__ (?) but to no avail.

Thanks again for your work, sorry for the spam today :)

贡献指南

这个仓库没有索引到贡献指南

从这里开始

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

调研方向

首先阅读 ActionView 的实现,尤其是 init_subclass 和 _deque 的初始化路径。复现 issue 中的子类示例,并检查请求处理如何使用队列。完成后的实现应提供受支持的子类级队列长度,同时不会使请求挂起,并包含覆盖配置的最大值的测试。

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

评估

技术栈
python
领域
backend
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
30/100

把新 issue 发到你的邮箱

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