-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #212 from martincollignon/temp/file-comparison
Temp/file comparison
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import asyncio | ||
import os | ||
from pathlib import Path | ||
import sys | ||
import logging | ||
from typing import Optional | ||
import signal | ||
from dotenv import load_dotenv | ||
|
||
logging.basicConfig( | ||
level=logging.INFO, | ||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', | ||
handlers=[logging.StreamHandler()] | ||
) | ||
logger = logging.getLogger(__name__) | ||
|
||
backend_dir = Path(__file__).parent.parent | ||
sys.path.append(str(backend_dir)) | ||
|
||
from src.sources.parsers.property_owners import PropertyOwnersParser | ||
from src.config import SOURCES | ||
|
||
shutdown = asyncio.Event() | ||
|
||
def handle_shutdown(signum, frame): | ||
logger.info(f"Received signal {signum}. Starting graceful shutdown...") | ||
shutdown.set() | ||
|
||
signal.signal(signal.SIGTERM, handle_shutdown) | ||
signal.signal(signal.SIGINT, handle_shutdown) | ||
|
||
async def main() -> Optional[int]: | ||
"""Sync property owners data to Cloud Storage""" | ||
load_dotenv() | ||
try: | ||
property_owners = PropertyOwnersParser(SOURCES["property_owners"]) | ||
total_synced = await property_owners.sync() | ||
logger.info(f"Total records synced: {total_synced:,}") | ||
return total_synced | ||
except Exception as e: | ||
logger.error(f"Error during sync: {str(e)}") | ||
raise | ||
|
||
if __name__ == "__main__": | ||
try: | ||
asyncio.run(main()) | ||
except KeyboardInterrupt: | ||
logger.info("Received keyboard interrupt. Shutting down...") | ||
except Exception as e: | ||
logger.error(f"Unhandled exception: {str(e)}") | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters