Answers for "how to run two functions in the same time in python in loop"

1

python run 2 functions at the same time

from threading import Thread

def func1():
    print('worker 1')

def func2():
    print("worker 2")

if __name__ == '__main__':
    a = Thread(target = func1)
    b = Thread(target = func2)
    a.start()
    b.start()
Posted by: Guest on February-18-2021
1

python 2 loops at the same time

# You can use threading
import threading # python 3.9.1

def Task_One():
    while True:
        print('Rawr')
        
def Task_Two():
    while True:
        print('de.cxl ig <3')

# Use variable or instantly start thread
        
threading.Thread(target=Task_One).start() # Task_One()
threading.Thread(target=Task_Two).start() # Task_Two()
Posted by: Guest on January-24-2021

Code answers related to "how to run two functions in the same time in python in loop"

Python Answers by Framework

Browse Popular Code Answers by Language