threading programming in python
I have not threading solution: I'm using celery for hard operations: send email, fetch url, create many database records, periodic tasks.
+ you can use flask application and celery instances on different servers
- you need backend (rabbitmq, redis, mongodb and etc.)
Recently I've been practicing to build a website with flask. Now i encounter a problem.There is a function which to achieve registration. The code like this:

    def register():
        ...
        some judgment
        ...
        if true:
        sendmail()
        return redirect(url_for('onepage'))

My question is :
When preforming sendmail(), it needs much time. So the users have to wait for a moment to get "onepage", about 4-5s. This will bring a bad experience.   I know that using threading can let these two functions independently of each other, but I have learnt programming for a very short time so I have no experience in threading programming, Could anybody provide some ideas or code examples for me at this problem?