wireup
wireup copied to clipboard
Add support for generator factories
I want to do something like the following:
@service
def create_transaction() -> Iterator[Transaction]:
transaction = Transaction()
try:
yield transaction
finally:
transaction.commit()
and also an async version:
@service
async def create_transaction() -> AsyncIterator[Transaction]:
transaction = Transaction()
try:
yield transaction
finally:
await transaction.commit()