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

11 statements  

« prev     ^ index     » next       coverage.py v7.0.1, created at 2022-12-31 16:00 +0000

1''' 

2Functions that implement relevant parts of the UWSGI API 

3''' 

4from functools import wraps 

5 

6handler_calls = [] 

7 

8 

9def spool(func): 

10 ''' 

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

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

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

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

15 ''' 

16 @wraps(func) 

17 def _(arg_dict): 

18 global handler_calls 

19 if len(handler_calls) >= 100: 

20 handler_calls = [] 

21 handler_calls.append(arg_dict) 

22 if arg_dict.pop('test_run', False): 

23 return func(arg_dict) 

24 return _