-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaskrunner.py
29 lines (24 loc) · 954 Bytes
/
taskrunner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from apscheduler.schedulers.blocking import BlockingScheduler
sched = BlockingScheduler()
from weather import *
import os
@sched.scheduled_job('interval', hours=3)
def weatehrupdate():
try:
connection = psycopg2.connect(user = os.environ["DB_USER"],
password = os.environ["DB_PASS"],
host = os.environ["DB_HOST"],
port = os.environ["DB_PORT"],
database = os.environ["DB_NAME"] )
cursor = connection.cursor()
connection.autocommit = True
except (Exception, psycopg2.Error) as error :
print ("Error while connecting to PostgreSQL", error)
finally:
if(connection):
cursor.close()
connection.close()
@sched.scheduled_job('interval', hours=16)
def timed_job2():
print('This is the number in number.txt: {0}')
sched.start()