|
5 | 5 |
|
6 | 6 | import pythonmonkey as pm |
7 | 7 |
|
| 8 | + |
8 | 9 | def printTimersDebugInfo(): |
9 | | - pm.eval("""(require) => { |
10 | | - const internalBinding = require('internal-binding'); |
11 | | - const { getAllRefedTimersDebugInfo: getDebugInfo } = internalBinding('timers'); |
12 | | - console.log(getDebugInfo()) |
13 | | - console.log(new Date()) |
14 | | - }""")(pm.createRequire(__file__)) |
| 10 | + pm.eval("""(require) => { |
| 11 | + const internalBinding = require('internal-binding'); |
| 12 | + const { getAllRefedTimersDebugInfo: getDebugInfo } = internalBinding('timers'); |
| 13 | + console.log(getDebugInfo()) |
| 14 | + console.log(new Date()) |
| 15 | + }""")(pm.createRequire(__file__)) |
| 16 | + |
15 | 17 |
|
16 | 18 | class WTF: |
17 | | - """ |
18 | | - WTFPythonMonkey to use as a Python context manager (`with`-statement) |
19 | | -
|
20 | | - Usage: |
21 | | - ```py |
22 | | - from pythonmonkey.lib.wtfpm import WTF |
23 | | -
|
24 | | - with WTF(): |
25 | | - # the main entry point for the program utilizes PythonMonkey event-loop |
26 | | - asyncio.run(pythonmonkey_main()) |
27 | | - ``` |
28 | | - """ |
29 | | - def __enter__(self): |
30 | | - pass |
31 | | - def __exit__(self, errType, errValue, traceback): |
32 | | - if errType is None: # no exception |
33 | | - return |
34 | | - elif issubclass(errType, KeyboardInterrupt): # except KeyboardInterrupt: |
35 | | - printTimersDebugInfo() |
36 | | - return True # exception suppressed |
37 | | - else: # other exceptions |
38 | | - return False |
| 19 | + """ |
| 20 | + WTFPythonMonkey to use as a Python context manager (`with`-statement) |
| 21 | +
|
| 22 | + Usage: |
| 23 | + ```py |
| 24 | + from pythonmonkey.lib.wtfpm import WTF |
| 25 | +
|
| 26 | + with WTF(): |
| 27 | + # the main entry point for the program utilizes PythonMonkey event-loop |
| 28 | + asyncio.run(pythonmonkey_main()) |
| 29 | + ``` |
| 30 | + """ |
| 31 | + |
| 32 | + def __enter__(self): |
| 33 | + pass |
| 34 | + |
| 35 | + def __exit__(self, errType, errValue, traceback): |
| 36 | + if errType is None: # no exception |
| 37 | + return |
| 38 | + elif issubclass(errType, KeyboardInterrupt): # except KeyboardInterrupt: |
| 39 | + printTimersDebugInfo() |
| 40 | + return True # exception suppressed |
| 41 | + else: # other exceptions |
| 42 | + return False |
0 commit comments