def asynchronize(
        motor_class,
        framework,
        sync_method,
        has_write_concern,
        doc=None):
    @functools.wraps(sync_method)
    def method(self, *args, **kwargs):
        check_deprecated_kwargs(kwargs)
        loop = self.get_io_loop()
        callback = kwargs.pop('callback', None)

        if callback:
            if not callable(callback):
                raise callback_type_error
            future = None
        else:
            future = framework.get_future(self.get_io_loop())

        def call_method():
            # Runs on child greenlet.
            try:
                result = sync_method(self.delegate, *args, **kwargs)
                if callback:
                    # Schedule callback(result, None) on main greenlet.
                    framework.call_soon(
                        loop,
                        functools.partial(callback, result, None))
                else:
                    # Schedule future to be resolved on main greenlet.
                    framework.call_soon(
                        loop,
                        functools.partial(future.set_result, result))
            except Exception as e:
                if callback:
                    framework.call_soon(
                        loop,
                        functools.partial(callback, None, e))
                else:
                    # TODO: we lost Tornado's set_exc_info. Frameworkify this.
                    framework.call_soon(
                        loop,
                        functools.partial(future.set_exception, e))

        # Start running the operation on a greenlet.
        greenlet.greenlet(call_method).switch()
        return future

    # This is for the benefit of motor_extensions.py, which needs this info to
    # generate documentation with Sphinx.
    method.is_async_method = True
    method.has_write_concern = has_write_concern
    name = sync_method.__name__
    method.pymongo_method_name = mangle_delegate_name(motor_class, name)
    if doc is not None:
        method.__doc__ = doc

    return method
Creates the toolkit-specific control that represents the view.
dataset/ETHPy150Open mongodb/motor/motor/metaprogramming.py/asynchronize--crossover with--dataset/ETHPy150Open enthought/pyface/pyface/workbench/debug/debug_view.py/DebugView.create_control