Threads


In [2]:
def salvar_arquivo(filename, conteudo):
    with open(filename, 'w') as f:
        f.write(conteudo)
#     f = open(filename, 'w')
#     f.write(conteudo)
#     f.flush()
#     f.close()

In [3]:
import threading

In [6]:
thread = threading.Thread(
    target=salvar_arquivo, args=['thread.txt', 'teste']
)

In [7]:
thread


Out[7]:
<Thread(Thread-5, initial)>

In [8]:
thread.start()

In [9]:
threading.Thread(
    target=salvar_arquivo, kwargs={
        'filename': 'thread2.txt', 'conteudo': 'teste'
    }
).start()

In [ ]: