Repository: getsentry/sentry-python

Issue:
Half installed AioHttpIntegration causes aiohttp to crash
If I call:
```python
sentry_sdk.integrations.setup_integrations(
        [sentry_sdk.integrations.aiohttp.AioHttpIntegration()])
```
after `sentry_sdk.init()` the `_handle` method of `aiohttp.web.Application` gets replaced but the integration does not get registered in the client. This causes the replaced `_handle` ro run into a codepath where there as a `await` missing. This gives an exception in every request:
```
ERROR:aiohttp.server:Unhandled exception                                                                                                                                                                                                                             
Traceback (most recent call last):                                                                                                                            
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 447, in start                                                                                                                                                                          
    await resp.prepare(request)                                                                                                                               
AttributeError: 'coroutine' object has no attribute 'prepare'                                                                                                                                                                                                        
/usr/local/lib/python3.7/site-packages/xxx/base.py:151: RuntimeWarning: coroutine 'Application._handle' was never awaited                              
  self._loop.run_forever()     
```

This will not get logged to sentry at all, because the `aiohttp.server` logger gets ignored by (half-)installing the integration (see #259).


Discussion:

Resolving patch:
diff --git a/sentry_sdk/integrations/aiohttp.py b/sentry_sdk/integrations/aiohttp.py
--- a/sentry_sdk/integrations/aiohttp.py
+++ b/sentry_sdk/integrations/aiohttp.py
@@ -32,7 +32,7 @@ async def sentry_app_handle(self, request, *args, **kwargs):
             async def inner():
                 hub = Hub.current
                 if hub.get_integration(AioHttpIntegration) is None:
-                    return old_handle(self, request, *args, **kwargs)
+                    return await old_handle(self, request, *args, **kwargs)
 
                 weak_request = weakref.ref(request)
 


Test patch:
diff --git a/tests/integrations/aiohttp/test_aiohttp.py b/tests/integrations/aiohttp/test_aiohttp.py
--- a/tests/integrations/aiohttp/test_aiohttp.py
+++ b/tests/integrations/aiohttp/test_aiohttp.py
@@ -53,3 +53,22 @@ async def hello(request):
     assert resp.status == 403
 
     assert not events
+
+
+async def test_half_initialized(sentry_init, aiohttp_client, loop, capture_events):
+    sentry_init(integrations=[AioHttpIntegration()])
+    sentry_init()
+
+    async def hello(request):
+        return web.Response(text="hello")
+
+    app = web.Application()
+    app.router.add_get("/", hello)
+
+    events = capture_events()
+
+    client = await aiohttp_client(app)
+    resp = await client.get("/")
+    assert resp.status == 200
+
+    assert events == []