From 0fae0715f8e504284386def63b4f512a87a4a801 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 18 Jul 2019 13:32:11 -0300 Subject: Handle MemoryError --- grab-queue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/grab-queue b/grab-queue index dbdc030..bfeaf40 100755 --- a/grab-queue +++ b/grab-queue @@ -271,13 +271,13 @@ if __name__ == "__main__": parser.set_defaults(progress=True) args = parser.parse_args() + # Initialize our dumper + queue = GrabQueue(args) + # Dispatch try: start_time = time.time() - # Initialize our dumper - queue = GrabQueue(args) - # Record date and invocation logs = ''.join(args.dest) + os.sep + 'logs' + os.sep queue.download.ensuredir(logs) @@ -298,6 +298,10 @@ if __name__ == "__main__": elapsed = open(logs + 'grab-queue.duration', 'a') elapsed.write(str(start_time) + '\t' + str(end_time) + '\t' + duration) elapsed.close() + except MemoryError as e: + print(e) + queue.dump_stats() + exit(1) except (FileNotFoundError, KeyboardInterrupt, subprocess.CalledProcessError) as e: print(e) exit(1) -- cgit v1.2.3