Skip to content

Commit 2d44224

Browse files
committed
Add main method
1 parent 50e0d7a commit 2d44224

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

webjobs/user_data_sync/start.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
import sys
12
import constants
23
from models import database
34
from user_data_sync_service import UserDataSyncService
45

6+
def main():
7+
try:
8+
database.connect()
9+
user_data_sync_service = UserDataSyncService()
10+
user_data_sync_service.sync()
11+
except:
12+
print("Unexpected error: ", sys.exc_info()[0])
13+
finally:
14+
database.close()
515

6-
database.connect()
7-
8-
user_data_sync_service = UserDataSyncService()
9-
user_data_sync_service.sync()
10-
11-
database.close()
16+
if __name__ == "__main__":
17+
main()

0 commit comments

Comments
 (0)