def get_current_task():
        """
        Implementation of asyncio.current_task()
        that returns None if there is no task.
        """
        try:
            return asyncio.current_task()
        except RuntimeError:
            return None

        Implementation of asyncio.current_task()
        that returns None if there is no task.
        
src/asgiref/sync.py