kalong 0.5.1__py3-none-any.whl → 0.5.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kalong/__init__.py +1 -1
- kalong/communication.py +29 -16
- kalong/config.py +3 -0
- kalong/server.py +7 -1
- kalong/static/assets/{index-BwfqANhu.js → index-B6z5WP1H.js} +49 -49
- kalong/static/index.html +1 -1
- kalong/stepping.py +3 -1
- kalong/tracing.py +16 -2
- kalong/utils/io.py +4 -2
- kalong/utils/obj.py +9 -1
- {kalong-0.5.1.dist-info → kalong-0.5.3.dist-info}/METADATA +2 -2
- {kalong-0.5.1.dist-info → kalong-0.5.3.dist-info}/RECORD +15 -15
- {kalong-0.5.1.dist-info → kalong-0.5.3.dist-info}/WHEEL +1 -1
- {kalong-0.5.1.dist-info → kalong-0.5.3.dist-info}/entry_points.txt +0 -0
- {kalong-0.5.1.dist-info → kalong-0.5.3.dist-info}/licenses/LICENSE +0 -0
kalong/__init__.py
CHANGED
kalong/communication.py
CHANGED
|
@@ -32,17 +32,15 @@ basicConfig(level=config.log_level)
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
def exception_handler(loop, context):
|
|
35
|
-
|
|
36
|
-
message = context["message"]
|
|
37
|
-
logging.error(f"Task failed, msg={message}, exception={exception}")
|
|
35
|
+
logging.error(f"Loop exit: {context}")
|
|
38
36
|
|
|
39
37
|
|
|
40
|
-
def communicate(frame, event, arg):
|
|
38
|
+
def communicate(frame, event, arg, pending=None):
|
|
41
39
|
loop = get_loop()
|
|
42
40
|
|
|
43
41
|
loop.set_exception_handler(exception_handler)
|
|
44
42
|
try:
|
|
45
|
-
loop.run_until_complete(communication_loop(frame, event, arg))
|
|
43
|
+
loop.run_until_complete(communication_loop(frame, event, arg, pending))
|
|
46
44
|
except asyncio.CancelledError:
|
|
47
45
|
log.info("Loop got cancelled")
|
|
48
46
|
die()
|
|
@@ -84,6 +82,7 @@ async def handle_message(ws, data, frame, event, arg):
|
|
|
84
82
|
|
|
85
83
|
elif data["type"] == "SET_PROMPT" or data["type"] == "REFRESH_PROMPT":
|
|
86
84
|
try:
|
|
85
|
+
step_frame = get_frame(frame, data.get("frame"), tb)
|
|
87
86
|
eval_fun = (
|
|
88
87
|
serialize_inspect_eval
|
|
89
88
|
if data.get("command") == "inspect"
|
|
@@ -95,16 +94,27 @@ async def handle_message(ws, data, frame, event, arg):
|
|
|
95
94
|
if data.get("command") == "recursive_debug"
|
|
96
95
|
else serialize_answer
|
|
97
96
|
)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
data
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
97
|
+
|
|
98
|
+
def get_response():
|
|
99
|
+
return {
|
|
100
|
+
"type": "SET_ANSWER",
|
|
101
|
+
"key": data["key"],
|
|
102
|
+
"command": data.get("command"),
|
|
103
|
+
"frame": data.get("frame"),
|
|
104
|
+
**eval_fun(data["prompt"], step_frame),
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if data.get("command") == "condition":
|
|
108
|
+
add_step("continue", step_frame, condition=get_response)
|
|
109
|
+
response = {
|
|
110
|
+
"type": "DO_COMMAND",
|
|
111
|
+
"command": "continue",
|
|
112
|
+
"frame": data.get("frame"),
|
|
113
|
+
"stop": True,
|
|
114
|
+
}
|
|
115
|
+
else:
|
|
116
|
+
response = get_response()
|
|
117
|
+
|
|
108
118
|
except SetFrameError as e:
|
|
109
119
|
frame = e.frame
|
|
110
120
|
event = e.event
|
|
@@ -162,7 +172,7 @@ async def handle_message(ws, data, frame, event, arg):
|
|
|
162
172
|
return response
|
|
163
173
|
|
|
164
174
|
|
|
165
|
-
async def communication_loop(frame_, event_, arg_):
|
|
175
|
+
async def communication_loop(frame_, event_, arg_, pending=None):
|
|
166
176
|
frame = frame_
|
|
167
177
|
event = event_
|
|
168
178
|
arg = arg_
|
|
@@ -178,6 +188,9 @@ async def communication_loop(frame_, event_, arg_):
|
|
|
178
188
|
if existing:
|
|
179
189
|
# If the socket is already opened we need to update client state
|
|
180
190
|
await init(ws, frame, event, arg)
|
|
191
|
+
if pending:
|
|
192
|
+
# Start by sending pending message
|
|
193
|
+
await ws.send_json(pending)
|
|
181
194
|
# Otherwise if it's new, just wait for HELLO to answer current state
|
|
182
195
|
|
|
183
196
|
stop = False
|
kalong/config.py
CHANGED
kalong/server.py
CHANGED
|
@@ -109,6 +109,10 @@ async def websocket(request):
|
|
|
109
109
|
return ws
|
|
110
110
|
|
|
111
111
|
|
|
112
|
+
def exception_handler(loop, context):
|
|
113
|
+
logging.error(f"Loop exit: {context}")
|
|
114
|
+
|
|
115
|
+
|
|
112
116
|
def serve():
|
|
113
117
|
app = web.Application()
|
|
114
118
|
app["front"] = {}
|
|
@@ -116,4 +120,6 @@ def serve():
|
|
|
116
120
|
app.on_shutdown.append(shutdown)
|
|
117
121
|
app.router.add_get(r"/{side:(front|back)}/{origin}", websocket)
|
|
118
122
|
app.router.add_static("/assets/", Path(__file__).parent / "static" / "assets")
|
|
119
|
-
|
|
123
|
+
loop = asyncio.get_event_loop()
|
|
124
|
+
loop.set_exception_handler(exception_handler)
|
|
125
|
+
web.run_app(app, host=config.host, port=config.port, print=False, loop=loop)
|