|
19 | 19 | # Opcode of "yield from" instruction |
20 | 20 | _YIELD_FROM = opcode.opmap['YIELD_FROM'] |
21 | 21 |
|
22 | | -# If you set _DEBUG to true, @coroutine will wrap the resulting |
23 | | -# generator objects in a CoroWrapper instance (defined below). That |
24 | | -# instance will log a message when the generator is never iterated |
25 | | -# over, which may happen when you forget to use "yield from" with a |
26 | | -# coroutine call. Note that the value of the _DEBUG flag is taken |
27 | | -# when the decorator is used, so to be of any use it must be set |
28 | | -# before you define your coroutines. A downside of using this feature |
29 | | -# is that tracebacks show entries for the CoroWrapper.__next__ method |
30 | | -# when _DEBUG is true. |
31 | | -_DEBUG = (not sys.flags.ignore_environment and |
32 | | - bool(os.environ.get('PYTHONASYNCIODEBUG'))) |
| 22 | + |
| 23 | +def _is_debug_mode(): |
| 24 | + # If you set _DEBUG to true, @coroutine will wrap the resulting |
| 25 | + # generator objects in a CoroWrapper instance (defined below). That |
| 26 | + # instance will log a message when the generator is never iterated |
| 27 | + # over, which may happen when you forget to use "yield from" with a |
| 28 | + # coroutine call. Note that the value of the _DEBUG flag is taken |
| 29 | + # when the decorator is used, so to be of any use it must be set |
| 30 | + # before you define your coroutines. A downside of using this feature |
| 31 | + # is that tracebacks show entries for the CoroWrapper.__next__ method |
| 32 | + # when _DEBUG is true. |
| 33 | + debug = (not sys.flags.ignore_environment and |
| 34 | + bool(os.environ.get('PYTHONASYNCIODEBUG'))) |
| 35 | + if hasattr(sys, '_xoptions') and 'dev' in sys._xoptions: |
| 36 | + debug = True |
| 37 | + return debug |
| 38 | + |
| 39 | + |
| 40 | +_DEBUG = _is_debug_mode() |
33 | 41 |
|
34 | 42 |
|
35 | 43 | try: |
|
0 commit comments