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
New pattern for async view classes #1512
Conversation
I've decided to make the clever import asyncio
from datasette.utils.asyncdi import AsyncBase, inject
class Simple(AsyncBase):
def __init__(self):
self.log = []
@inject
async def two(self):
self.log.append("two")
@inject
async def one(self, two):
self.log.append("one")
return self.log
async def not_inject(self, one, two):
return one + two
class Complex(AsyncBase):
inject_all = True
def __init__(self):
self.log = []
async def b(self):
self.log.append("b")
async def a(self, b):
self.log.append("a")
async def go(self, a):
self.log.append("go")
return self.log |
Codecov Report
@@ Coverage Diff @@
## main #1512 +/- ##
==========================================
- Coverage 91.82% 89.72% -2.11%
==========================================
Files 34 36 +2
Lines 4430 4604 +174
==========================================
+ Hits 4068 4131 +63
- Misses 362 473 +111
Continue to review full report at Codecov.
|
Oh no - the vendored code I use has |
I made the changes locally and tested them with Python 3.6 like so:
|
I'm going to extract out the |
https://github.com/simonw/asyncinject version 0.1a0 is now live on PyPI: https://pypi.org/project/asyncinject/ |
Closing this PR because I shipped the code in it as a separate library instead. |
Refs #878 - starting out with the new
AsyncBase
class implementing a pytest-inspiredasyncio
parallel execution mechanism.