How to start multithreading to monitor the database and execute scripts according to the status when Flask starts

there is a problem in the WEB project, which requires the background to refresh and monitor the data in the database in real time.
every time FLASK starts, it starts a thread to monitor the order placed by the customer and whether the order has been paid successfully.
after the customer changes the database state after the payment is successful, one more thread is opened to execute the script to ship the order.
how to implement it in Flask?


consider using ThreadPoolExecutor in concurrent.futures

from concurrent.futures import ThreadPoolExecutor
executor = ThreadPoolExecutor(2) -sharp
...
executor.submit(your_function)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35469-2bf73.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35469-2bf73.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?