Coverage for rfpy/jobs/uwsgi_stubs.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-04-24 10:52 +0000

1""" 

2Functions that implement relevant parts of the UWSGI API 

3""" 

4 

5from typing import Callable 

6from functools import wraps 

7 

8handler_calls: list[dict] = [] 

9 

10 

11def spool(func) -> Callable: 

12 """ 

13 Replaces the uwsgi @spool decorator when the app is not running under UWSGI 

14 By default, the wrapped function is *not* called, but arguments passed are 

15 recorded in handler_calls. At most 100 handler call arguments are recorded. 

16 If the kwarg param 'test_run' is set to True then the wrapped function is called 

17 """ 

18 

19 @wraps(func) 

20 def _(arg_dict): 

21 global handler_calls 

22 if len(handler_calls) >= 100: 

23 handler_calls = [] 

24 handler_calls.append(arg_dict) 

25 if arg_dict.pop("test_run", False): 

26 return func(arg_dict) 

27 

28 return _