File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ import gc
34import os
45import shutil
56import subprocess
@@ -197,14 +198,15 @@ def __performance(self):
197198
198199 execution_times = []
199200 memory_usage = []
200- process = psutil .Process ()
201+ process = psutil .Process (os . getpid () )
201202
202203 for file in range (len (self .execution_list )):
204+ gc .collect ()
203205 start_time = datetime .now ()
204- start_memory = process .memory_info ().rss / 1024 / 1024 # MB
206+ start_memory = process .memory_full_info ().uss / 1024 / 1024 # MB
205207 log .execution (Execute .script (self .execution_list [file ]))
206208 end_time = datetime .now ()
207- end_memory = process .memory_info ().rss / 1024 / 1024 # MB
209+ end_memory = process .memory_full_info ().uss / 1024 / 1024 # MB
208210 elapsed_time = end_time - start_time
209211 memory_delta = end_memory - start_memory
210212 memory_usage .append ((self .execution_list [file ], str (memory_delta )))
@@ -510,8 +512,8 @@ def Logicytics():
510512 try :
511513 Logicytics ()
512514 except KeyboardInterrupt :
513- log .warning ("Shutting down Logicytics utility with force causes many files to remain where they shouldn't " )
514- log .warning ("Please don't force shut Logicytics again - As we don't have a cleanup function yet ." )
515+ log .warning ("⚠️ Force shutdown detected! Some temporary files might be left behind. " )
516+ log .warning ("💡 Pro tip: Next time, let the program finish naturally ." )
515517 # TODO v3.4.2 -> Cleanup function
516518 exit (0 )
517519else :
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3- import functools
43import os
5- import time
6-
7-
8- def time_execution (func ):
9- """
10- A decorator that logs the execution time of a function.
11-
12- Usage:
13- @time_execution
14- def my_function():
15- ...
16-
17- Or:
18- time_execution(my_function, *args, **kwargs)
19- """
20-
21- @functools .wraps (func )
22- def wrapper (* args , ** kwargs ):
23- start_time = time .time ()
24- result = func (* args , ** kwargs )
25- end_time = time .time ()
26- print (f"Function '{ func .__name__ } ' executed in { end_time - start_time :.6f} seconds" )
27- return result
28-
29- return wrapper
304
315
326class Get :
337 @staticmethod
34- @time_execution
358 def list_of_files (
369 directory : str ,
3710 only_extensions : list [str ] = None ,
Original file line number Diff line number Diff line change 2525class ObjectLoadError (Exception ):
2626 """Raised when an Object fails to load."""
2727
28- def __init__ (self , message = "Failed to load object" ):
28+ def __init__ (self , message = "Failed to load object" , object_name = None ):
29+ """
30+ Initialize the exception with a custom message and object details.
31+
32+ Args:
33+ message (str): The error message
34+ object_name (str, optional): Name of the object that failed to load
35+ """
36+ self .object_name = object_name
37+ if object_name :
38+ message = f"{ message } (Object: { object_name } )"
2939 super ().__init__ (message )
3040
3141
You can’t perform that action at this time.
0 commit comments