mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-11-04 04:29:13 +00:00 
			
		
		
		
	MINOR - Only timeout on main threads (#18341)
This commit is contained in:
		
							parent
							
								
									c7a466b674
								
							
						
					
					
						commit
						5e80ad9fc3
					
				@ -18,6 +18,7 @@ import inspect
 | 
				
			|||||||
import os
 | 
					import os
 | 
				
			||||||
import platform
 | 
					import platform
 | 
				
			||||||
import signal
 | 
					import signal
 | 
				
			||||||
 | 
					import threading
 | 
				
			||||||
from typing import Callable
 | 
					from typing import Callable
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from metadata.utils.constants import TEN_MIN
 | 
					from metadata.utils.constants import TEN_MIN
 | 
				
			||||||
@ -47,7 +48,11 @@ def timeout(seconds: int = TEN_MIN) -> Callable:
 | 
				
			|||||||
    def decorator(fn):
 | 
					    def decorator(fn):
 | 
				
			||||||
        @functools.wraps(fn)
 | 
					        @functools.wraps(fn)
 | 
				
			||||||
        def inner(*args, **kwargs):
 | 
					        def inner(*args, **kwargs):
 | 
				
			||||||
            if platform.system() != "Windows":  # SIGALRM not supported on Windows
 | 
					            # SIGALRM is not supported on Windows or sub-threads
 | 
				
			||||||
 | 
					            if (
 | 
				
			||||||
 | 
					                platform.system() != "Windows"
 | 
				
			||||||
 | 
					                and threading.current_thread() == threading.main_thread()
 | 
				
			||||||
 | 
					            ):
 | 
				
			||||||
                signal.signal(signal.SIGALRM, _handle_timeout)
 | 
					                signal.signal(signal.SIGALRM, _handle_timeout)
 | 
				
			||||||
                signal.alarm(seconds)
 | 
					                signal.alarm(seconds)
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user