<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def call_from_thread(self, fn):
 """Allow thread-safe calls to ioloop functions. Uses add_callback if not in the IOLoop thread, otherwise calls directly. Returns an already resolved `tornado.concurrent.Future` if in ioloop, otherwise a `concurrent.Future`. Logs unhandled exceptions. Resolves with an exception if one occurred. """

        if self.in_ioloop_thread():
            f = tornado_Future()
            try:
                f.set_result(fn())
            except Exception, e:
                f.set_exception(e)
                self._logger.exception('Error executing callback '
                                       'in ioloop thread')
            finally:
                return f
        else:
            f = Future()
            try:
                f.set_running_or_notify_cancel()

                def send_message_callback():
                    try:
                        f.set_result(fn())
                    except Exception, e:
                        f.set_exception(e)
                        self._logger.exception(
                            'Error executing wrapped async callback')

                self.ioloop.add_callback(send_message_callback)
            finally:
                return f