<s> from circus . plugins . statsd import BaseObserver <EOL> try : <EOL> from tornado . httpclient import AsyncHTTPClient <EOL> except ImportError : <EOL> raise ImportError ( "<STR_LIT>" ) <EOL> class HttpObserver ( BaseObserver ) : <EOL> name = '<STR_LIT>' <EOL> default_app_name = "<STR_LIT>" <EOL> def __init__ ( self , * args , ** config ) : <EOL> super ( HttpObserver , self ) . __init__ ( * args , ** config ) <EOL> self . http_client = AsyncHTTPClient ( io_loop = self . loop ) <EOL> self . check_url = config . get ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . timeout = float ( config . get ( "<STR_LIT>" , <NUM_LIT:10> ) ) <EOL> self . restart_on_error = config . get ( "<STR_LIT>" , None ) <EOL> def look_after ( self ) : <EOL> def handle_response ( response , * args , ** kwargs ) : <EOL> if response . error : <EOL> self . statsd . increment ( "<STR_LIT>" ) <EOL> self . statsd . increment ( "<STR_LIT>" % response . code ) <EOL> if self . restart_on_error : <EOL> self . cast ( "<STR_LIT>" , name = self . restart_on_error ) <EOL> self . statsd . increment ( "<STR_LIT>" ) <EOL> return <EOL> self . statsd . timed ( "<STR_LIT>" , <EOL> int ( response . request_time * <NUM_LIT:1000> ) ) <EOL> self . http_client . fetch ( self . check_url , handle_response , <EOL> request_timeout = self . timeout ) </s>
