def inthread(func):
    """Decorator to call a function in a thread and return a deferred with the
    result
    """
    @wraps(func)
    def wrapped(*a, **kw):
        return threads.deferToThread(func, *a, **kw)
    return wrapped
Decorator to call a function in a thread and return a deferred with the
    result
    
stackoverflow/venv/lib/python3.6/site-packages/scrapy/utils/decorators.py