Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing ActionView._deque.maxlen in subclasses #300

Open
glyg opened this issue Nov 26, 2021 · 0 comments
Open

Changing ActionView._deque.maxlen in subclasses #300

glyg opened this issue Nov 26, 2021 · 0 comments

Comments

@glyg
Copy link

glyg commented Nov 26, 2021

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant