feat: Update check for payments timer
All checks were successful
Build Docker / Build Image (push) Successful in 22s
All checks were successful
Build Docker / Build Image (push) Successful in 22s
This commit is contained in:
5
main.py
5
main.py
@@ -7,6 +7,7 @@ import os
|
|||||||
import dotenv
|
import dotenv
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
from apscheduler.schedulers.background import BackgroundScheduler
|
||||||
|
|
||||||
|
|
||||||
class GunicornApp(BaseApplication):
|
class GunicornApp(BaseApplication):
|
||||||
@@ -24,6 +25,10 @@ class GunicornApp(BaseApplication):
|
|||||||
return self.application
|
return self.application
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
scheduler = BackgroundScheduler()
|
||||||
|
scheduler.add_job(func=server.check_payments, trigger="interval", seconds=10)
|
||||||
|
scheduler.start()
|
||||||
|
|
||||||
workers = os.getenv('WORKERS')
|
workers = os.getenv('WORKERS')
|
||||||
threads = os.getenv('THREADS')
|
threads = os.getenv('THREADS')
|
||||||
if workers is None:
|
if workers is None:
|
||||||
|
|||||||
@@ -293,13 +293,16 @@ def not_found(e):
|
|||||||
return render_template('404.html'), 404
|
return render_template('404.html'), 404
|
||||||
|
|
||||||
|
|
||||||
def repeat_check_payments():
|
def repeat_check_payments(auto=False):
|
||||||
# Run check_payments function
|
# Run check_payments function
|
||||||
payments.check_payments()
|
payments.check_payments()
|
||||||
# Schedule the function to run again after 10 seconds
|
# Schedule the function to run again after 10 seconds
|
||||||
|
if not auto:
|
||||||
threading.Timer(10, repeat_check_payments).start()
|
threading.Timer(10, repeat_check_payments).start()
|
||||||
|
|
||||||
|
def check_payments():
|
||||||
|
print('Checking payments', flush=True)
|
||||||
|
payments.check_payments()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Set timer for payments
|
# Set timer for payments
|
||||||
|
|||||||
Reference in New Issue
Block a user