def set_result(self, result):
result = result.result()[<NUM_LIT:0>]<EOL>if self.future is not None:<EOL><INDENT>if isinstance(result, Exception):<EOL><INDENT>self.future.set_exception(result)<EOL><DEDENT>else:<EOL><INDENT>self.future.set_result(result)<EOL><DEDENT>self.future = None<EOL><DEDENT>elif isinstance(result, Exception):<EOL><INDENT>raise result<EOL><DEDENT>
Set future's result if needed (can be an exception).
        Else raise if needed.