def on_message(self, message):
        """Evaluates the function pointed to by json-rpc."""
        json_rpc = json.loads(message)
        logging.log(logging.DEBUG, json_rpc)

        if self.pool is None:
            self.pool = multiprocessing.Pool(processes=args.workers)

        # Spawn a process to protect the server against segfaults
        async = self.pool.apply_async(_worker_process, [json_rpc])
        try:
            result = async.get(timeout=args.timeout)
            error = 0
        except multiprocessing.TimeoutError:
            result = ("File format conversion timed out! This is due "
                      "either to a large input file or a segmentation "
                      "fault in the underlying open babel library.")
            error = 1
            self.pool.terminate()
            self.pool = multiprocessing.Pool(processes=args.workers)
        except Exception:
            result = traceback.format_exc()
            error = 1
        logging.log(logging.DEBUG, result)

        self.write_message(json.dumps({'result': result, 'error': error,
                                       'id': json_rpc['id']},
                                      separators=(',', ':')))
def on_message ( self , message ) : json_rpc = json . loads ( message ) logging . log ( logging . DEBUG , json_rpc ) if self . pool is None : self . pool = multiprocessing . Pool ( processes = args . workers ) async = self . pool . apply_async ( _worker_process , [ json_rpc ] ) try : result = async . get ( timeout = args . timeout ) error = 0 except multiprocessing . TimeoutError : result = ( "File format conversion timed out! This is due " "either to a large input file or a segmentation " "fault in the underlying open babel library." ) error = 1 self . pool . terminate ( ) self . pool = multiprocessing . Pool ( processes = args . workers ) except Exception : result = traceback . format_exc ( ) error = 1 logging . log ( logging . DEBUG , result ) self . write_message ( json . dumps ( { 'result' : result , 'error' : error , 'id' : json_rpc [ 'id' ] } , separators = ( ',' , ':' ) ) )
Evaluates the function pointed to by json-rpc.