在Python中异步运行多个任务

在Python中异步运行多个任务,python,asynchronous,python-multithreading,Python,Asynchronous,Python Multithreading,这是我的一个端点中的最后两行: self.send_activation_mail(request, user=user) return self.response(request, status=201, title='Created', description='Please check your email for activation', data=user_data) 返回self.response将返回MyREST客户端201的响应。我的问题是send\u activation\u

这是我的一个端点中的最后两行:

self.send_activation_mail(request, user=user)
return self.response(request, status=201, title='Created', description='Please check your email for activation', data=user_data)

返回self.response将返回MyREST客户端201的响应。我的问题是
send\u activation\u mail
似乎需要时间才能运行,所以我的端点注册过程需要很多时间。我试图在Python中找到同时异步执行这些任务的方法。以前有人有过这种情况的经验吗?你是说你想异步执行这些任务吗。同步意味着在同一线程上按顺序执行所有内容


根据您的Python版本,您可以查看多处理模块:。

在我使用threading
threading.Thread(target=self.send\u activation\u mail(request=request,user=user)).start()执行send\u activation\u mail后解决了此问题。抱歉,我编辑了我的问题。这是否意味着如果我在不同的线程中运行两个不同的任务,并且其中一个任务是返回任务,那么在执行返回任务后是否取消了另一个任务?您可以尝试一下吗?