GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing taskiq-python.github.io — Taskiq + AioHTTP Taskiq + AioHTTP5/21/23 Taskiq + AioHTTPAioHTTP is a framework for building robust applications. We created several libraries to make the experience with AioHTTP even better. Dependency injection for AioHTTPWe created a library aiohttp-deps to add FastAPI-like dependency injection in AioHTTP. To install it, simply run: After the installation, please add startup event to your application to initialize dependencies context. You can read more about dependency injection and available dependencies in the project's README.md. Adding taskiq integrationWe highly recommend using aiohttp with aiohttp-deps because it allows us to reuse the same dependencies for your handlers and tasks. First of all, you should install the taskiq-aiohttp library. After the installation is complete, add an initialization function call to your broker's main file so it becomes something like this: From this point, you'll be able to reuse the same dependencies as with Annotated 3.10+ default values In this example, we depend on the current application. We can use its state in a current task or any other dependency. We can take db_pool from your application's state, which is the same pool, as the one you've created on AioHTTP's startup. But this application is only a mock of your application. It has correct types and all your variables that you filled on startup, but it doesn't handle any request. This integration adds two main dependencies:
You can find more detailed examples in the examples repo. TestingWriting tests for AioHTTP with taskiq is as easy as writing tests for the aiohttp application. The only difference is that, if you want to use InMemoryBroker, then you need to add context for dependency injection. It's easier to call |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |