jazzband / django-waffle

A feature flipper for Django
https://waffle.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.13k stars 258 forks source link

Plans for async support? #441

Open pgcd opened 2 years ago

pgcd commented 2 years ago

Are there plans to add async support (at least to views and middleware)? Alternatively, is there any demand for it?

clintonb commented 2 years ago

This is the first request. Pull requests are welcome.

schinckel commented 9 months ago

Okay, I have a work in progress: however it will likely change the existing decorators to use contextlib.ContextDecorator (and contextlib.AsyncContextDecorator). Is that going to be acceptable?

schinckel commented 9 months ago

Actually, looking at the code, it seems it already uses a subclass of that (via django.test.utils.TestContextDecorator).

I think I'll need to do more digging to find out how to make it work.

schinckel commented 9 months ago

Turned out the simplest thing to do was to wrap the test (inside the application of the waffle decorator), like show at the bottom of the section https://docs.djangoproject.com/en/5.0/topics/testing/tools/#testing-asynchronous-code