python_ asynchronous tasks

First, asynchronous tasks

Example:

 1 import yagmail,threading
 2 def send_mail():
 3     smtp = yagmail.SMTP(host='smtp.163.com',user='[email protected]',
 4                         password='fsdfsf')
 5     smtp.send(to = '[email protected]',cc=['[email protected]','[email protected]'],
 6               subject='标题',contents='正文' , R & lt Attachments = ' write log .py ' )
 . 7  
. 8  DEF async_send_mail ():    # start a thread dedicated mail 
. 9      T of the threading.Thread = (target = the send_mail)
 10      t.start ()

 

Guess you like

Origin www.cnblogs.com/xumb/p/11964124.html