<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from raven . transport . base import AsyncTransport <EOL> from raven . transport . http import HTTPTransport <EOL> try : <EOL> import gevent <EOL> try : <EOL> from gevent . lock import Semaphore <EOL> except ImportError : <EOL> from gevent . coros import Semaphore <EOL> has_gevent = True <EOL> except : <EOL> has_gevent = None <EOL> class GeventedHTTPTransport ( AsyncTransport , HTTPTransport ) : <EOL> scheme = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def __init__ ( self , parsed_url , maximum_outstanding_requests = <NUM_LIT:100> , * args , ** kwargs ) : <EOL> if not has_gevent : <EOL> raise ImportError ( '<STR_LIT>' ) <EOL> self . _lock = Semaphore ( maximum_outstanding_requests ) <EOL> super ( GeventedHTTPTransport , self ) . __init__ ( parsed_url , * args , ** kwargs ) <EOL> def async_send ( self , data , headers , success_cb , failure_cb ) : <EOL> """<STR_LIT>""" <EOL> self . _lock . acquire ( ) <EOL> return gevent . spawn ( <EOL> super ( GeventedHTTPTransport , self ) . send , data , headers <EOL> ) . link ( lambda x : self . _done ( x , success_cb , failure_cb ) ) <EOL> def _done ( self , greenlet , success_cb , failure_cb , * args ) : <EOL> self . _lock . release ( ) <EOL> if greenlet . successful ( ) : <EOL> success_cb ( ) <EOL> else : <EOL> failure_cb ( greenlet . exception ) </s>
