django-waffle icon indicating copy to clipboard operation
django-waffle copied to clipboard

Plans for async support?

Open pgcd opened this issue 3 years ago • 4 comments

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

pgcd avatar May 24 '22 12:05 pgcd

This is the first request. Pull requests are welcome.

clintonb avatar May 24 '22 14:05 clintonb

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 avatar Feb 05 '24 06:02 schinckel

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 avatar Feb 05 '24 06:02 schinckel

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

schinckel avatar Feb 05 '24 06:02 schinckel