wireup icon indicating copy to clipboard operation
wireup copied to clipboard

Add support for generator factories

Open cfxegbert opened this issue 6 months ago • 3 comments

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()

cfxegbert avatar Jul 31 '24 23:07 cfxegbert