-
Notifications
You must be signed in to change notification settings - Fork 69
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
The @atomic decorator now work for class grouped handler #31
Comments
Sorry, I don't see how to fix it in a generic way. |
It is a good idea, but for support back-compat, or just use def atomic(coro):
@wraps(coro)
async def wrapper(*args):
if inspect.ismethod(coro):
instance = args[0]
if isinstance(instance, View):
# Class Based View decorated.
request = instance.request
else:
# Method Based View
request = args[1]
else:
request = args[0]
job = await spawn(request, coro(request))
return await job.wait()
return wrapper but the code look is ugly, and more expensive. |
Yes.
That's why I did not support classes from very beginning (and still not sure what way is better now). |
Ok. We should postpone this issue if not have better idea. But maybe we can add some doc for illustrate? |
Doc example sounds perfect. |
Would the approach of https://github.com/nkoshell/aiojobs/commit/20d7a34a74b2fb50a968f875d704ea0279a5ae7e be reasonable? Just wondering because I’ve run into this same problem, but I don’t have enough Python fu to pick up the (apparently abandoned?) work myself. |
I watch aiohttp's doc, it teach me use the
aiojobs.atomic
to avoid request cancel.And I found it not work on class grouped handler, I don't mean class view, just this mean method handler:
I investigate the source code, ensure the
@atomic
decorator cause the problem.Traceback on class grouped handler
If you also think this is a bug, I can fix it
The text was updated successfully, but these errors were encountered: