I have two scripts. One of them checks out an online database and the other one checks a telegram bot. Both of them run in loop, but they take some time to check the updates, so I'd like to run them separately. Can I do that?
-
3Duplicate of How can I use threading in Python?esqew– esqew2021-12-18 22:12:14 +00:00Commented Dec 18, 2021 at 22:12
-
yes you can, you can either start both script manually for separate or you can run the both with any of the concurrent mechanism available such a threads of multiprocessesCopperfield– Copperfield2021-12-18 22:31:45 +00:00Commented Dec 18, 2021 at 22:31
Add a comment
|
1 Answer
Yes, you can. Use threading as suggested:
from threading import Thread
def one():
...
def two():
...
Thread(target=one).start()
Thread(target=two).start()