<s> """<STR_LIT>""" <EOL> import json <EOL> import decimal <EOL> import gearman <EOL> class _JSONEncoder ( json . JSONEncoder ) : <EOL> """<STR_LIT>""" <EOL> def default ( self , obj ) : <EOL> if isinstance ( obj , decimal . Decimal ) : <EOL> return str ( obj ) <EOL> return super ( _JSONEncoder , self ) . default ( obj ) <EOL> class _JSONDataEncoder ( gearman . DataEncoder ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> def encode ( cls , encodable_object ) : <EOL> return json . dumps ( encodable_object , cls = _JSONEncoder ) <EOL> @ classmethod <EOL> def decode ( cls , decodable_string ) : <EOL> return json . loads ( decodable_string ) <EOL> class GearmanWorker ( gearman . GearmanWorker ) : <EOL> """<STR_LIT>""" <EOL> data_encoder = _JSONDataEncoder <EOL> def after_poll ( self , any_activity ) : <EOL> return True <EOL> class GearmanClient ( gearman . GearmanClient ) : <EOL> """<STR_LIT>""" <EOL> data_encoder = _JSONDataEncoder </s>
