diff --git a/docs/config/index.rst b/docs/config/index.rst index d0f22afe..d344b648 100644 --- a/docs/config/index.rst +++ b/docs/config/index.rst @@ -9,6 +9,8 @@ This document describes configuration options available to Sentry. .. toctree:: :maxdepth: 2 + aiohttp + asyncio bottle celery django @@ -62,7 +64,11 @@ It is composed of six important pieces: * The project ID which the authenticated user is bound to. -.. note:: Protocol may also contain transporter type: gevent+http, gevent+https, twisted+http, tornado+http, eventlet+http, eventlet+https +.. note:: + + Protocol may also contain transporter type: gevent+http, gevent+https, twisted+http, tornado+http, eventlet+http, eventlet+https + + For *Python 3.3+* also available: aiohttp+http, aiohttp+https, asycio+udp Client Arguments ---------------- diff --git a/docs/transports/index.rst b/docs/transports/index.rst index 266fe279..fa054092 100644 --- a/docs/transports/index.rst +++ b/docs/transports/index.rst @@ -25,6 +25,15 @@ For example, to increase the timeout and to disable SSL verification: SENTRY_DSN = 'http://public:secret@example.com/1?timeout=5&verify_ssl=0' +aiohttp +------- + +Should only be used within a Tornado IO loop. + +:: + + SENTRY_DSN = 'aiohttp+http://public:secret@example.com/1' + Eventlet -------- diff --git a/raven/transport/__init__.py b/raven/transport/__init__.py index e98acaa7..87609d6f 100644 --- a/raven/transport/__init__.py +++ b/raven/transport/__init__.py @@ -22,5 +22,5 @@ from raven.transport.threaded import * # NOQA from raven.transport.tornado import * # NOQA from raven.transport.udp import * # NOQA -if sys.version_info() >= (3.3): - from raven.transport.asyncio import * # NOQA +if sys.version_info >= (3, 3): + from raven.transport.aiohttp import * # NOQA diff --git a/raven/transport/asyncio.py b/raven/transport/aiohttp.py similarity index 55% rename from raven/transport/asyncio.py rename to raven/transport/aiohttp.py index a0f7d769..07a8c951 100644 --- a/raven/transport/asyncio.py +++ b/raven/transport/aiohttp.py @@ -5,36 +5,30 @@ raven.transport.asyncio :copyright: (c) 2010-2014 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. """ -from __future__ import absolute_import - -import logging - from raven.transport.base import AsyncTransport from raven.transport.http import HTTPTransport -from raven.transport.udp import BaseUDPTransport try: - import asyncio import aiohttp - has_asyncio = True + import asyncio + has_aiohttp = True except: - has_asyncio = False + has_aiohttp = False -class AsyncioHttpTransport(AsyncTransport, HTTPTransport): +class AioHttpTransport(AsyncTransport, HTTPTransport): - scheme = ['asyncio+http', 'asyncio+https'] + scheme = ['aiohttp+http', 'aiohttp+https'] def __init__(self, parsed_url, *, loop=None): - if not has_asyncio: - raise ImportError('AIOHttpTransport requires asyncio and aiohttp.') + if not has_aiohttp: + raise ImportError('AioHttpTransport requires asyncio and aiohttp.') if loop is None: loop = asyncio.get_event_loop() self._loop = loop super().__init__(parsed_url) - self.logger = logging.getLogger('sentry.errors') # remove the aiohttp+ from the protocol, as it is not a real protocol self._url = self._url.split('+', 1)[-1] @@ -52,21 +46,3 @@ class AsyncioHttpTransport(AsyncTransport, HTTPTransport): except Exception as exc: failure_cb(exc) asyncio.async(f(), loop=self._loop) - - -class AsyncioUDPTransport(BaseUDPTransport): - scheme = ['asyncio+udp'] - - def __init__(self, parsed_url, *, loop=None): - super().__init__(parsed_url) - if not has_asyncio: - raise ImportError('AsyncioUDPTransport requires asyncio.') - if loop is None: - loop = asyncio.get_event_loop() - self._loop = loop - - self._transport, _ = loop.run_until_complete( - loop.create_datagram_endpoint(asyncio.DatagramProtocol)) - - def _send_data(self, data, addr): - self._transport.send_to(data, addr) diff --git a/raven/transport/registry.py b/raven/transport/registry.py index 1694fc36..71d01213 100644 --- a/raven/transport/registry.py +++ b/raven/transport/registry.py @@ -20,8 +20,8 @@ from raven.transport.tornado import TornadoHTTPTransport from raven.transport.udp import UDPTransport from raven.utils import urlparse -if sys.version_info() >= (3.3): - from raven.transport.asyncio import AsyncioHttpTransport +if sys.version_info >= (3, 3): + from raven.transport.aiohttp import AioHttpTransport class TransportRegistry(object): @@ -83,5 +83,5 @@ default_transports = [ EventletHTTPTransport, ] -if sys.version_info() >= (3.3): - default_transports += [AsyncioHttpTransport,] +if sys.version_info >= (3, 3): + default_transports += [AioHttpTransport] diff --git a/setup.py b/setup.py index 6d36b97e..370668b8 100755 --- a/setup.py +++ b/setup.py @@ -54,6 +54,11 @@ if sys.version_info[0] == 3: unittest2_requires = [] webpy_tests_requires = [] +if sys.version_info >= (3, 3): + aiohttp_requires = ['aiohttp'] +else: + aiohttp_requires = [] + tests_require = [ 'bottle', @@ -74,8 +79,8 @@ tests_require = [ 'webob', 'webtest', 'anyjson', -] + (flask_requires + flask_tests_requires + unittest2_requires + - webpy_tests_requires) +] + (aiohttp_requires + flask_requires + flask_tests_requires + + unittest2_requires + webpy_tests_requires) class PyTest(TestCommand):