Skip to content

Commit 8b9ae84

Browse files
committed
Merge branch 'release/0.1.2'
2 parents a305673 + 5b023d4 commit 8b9ae84

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "taskiq-aiohttp"
33
description = "Taskiq integration with AioHTTP framework"
44
authors = ["Taskiq team <taskiq@no-reply.com>"]
55
maintainers = ["Taskiq team <taskiq@no-reply.com>"]
6-
version = "0.1.1"
6+
version = "0.1.2"
77
readme = "README.md"
88
license = "LICENSE"
99
classifiers = [

taskiq_aiohttp/initializer.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,18 @@ async def startup(state: TaskiqState) -> None:
4444

4545
if inspect.iscoroutine(local_app):
4646
local_app = await local_app
47-
4847
if not isinstance(local_app, web.Application):
4948
raise ValueError(f"{app_path} is not an AioHTTP application.")
5049

51-
handler = RequestHandler(local_app._make_handler(), loop=loop)
50+
# Starting the application.
51+
app_runner = web.AppRunner(local_app)
52+
await app_runner.setup()
53+
54+
if app_runner.server is None:
55+
raise ValueError("Cannot construct aiohttp app to mock requests")
56+
57+
# Creating mocked request
58+
handler = RequestHandler(app_runner.server, loop=loop)
5259
handler.transport = asyncio.Transport()
5360
request = web.Request(
5461
RawRequestMessage(
@@ -88,9 +95,8 @@ async def startup(state: TaskiqState) -> None:
8895
},
8996
)
9097

91-
state.aiohttp_app = local_app
98+
state.aiohttp_runner = app_runner
9299
local_app.router._resources = []
93-
await local_app.startup()
94100

95101
return startup
96102

@@ -104,8 +110,8 @@ async def shutdown(state: TaskiqState) -> None:
104110
105111
:param state: current state.
106112
"""
107-
await state.aiohttp_app.shutdown()
108-
await state.aiohttp_app.cleanup()
113+
await state.aiohttp_runner.shutdown()
114+
await state.aiohttp_runner.cleanup()
109115

110116

111117
def init(broker: AsyncBroker, app_path: str) -> None:

0 commit comments

Comments
 (0)