File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -12,3 +12,27 @@ def printTimersDebugInfo():
1212 console.log(getDebugInfo())
1313 console.log(new Date())
1414 }""" )(pm .createRequire (__file__ ))
15+
16+ 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
You can’t perform that action at this time.
0 commit comments