diff --git a/fp2_10.py b/fp2_10.py index baf21ef..d459cf2 100644 --- a/fp2_10.py +++ b/fp2_10.py @@ -41,7 +41,7 @@ subscription = subscriber.create_subscription( # Publish a message to the topic # Read the data from the csv file # file_path = "C:/Users/Karen/Desktop/zipcodes.csv" -file_path = "C:/Users/Karen/Desktop/zipcodes.csv" +file_path = "zipcodes.csv" with open(file_path, "r") as csv_file: reader = csv.reader(csv_file) @@ -49,7 +49,10 @@ with open(file_path, "r") as csv_file: for row in reader: # Format the data as a string and publish it to the topic data = ",".join(row).encode("utf-8") - future = publisher.publish(topic_path, data) + try: + future = publisher.publish(topic_path, data) + except DeadlineExceeded as de: + print(f"Caught DeadlineExceeded exception: {de}") print(f"Published message ID {future.result()}") '''