Skip to content

Commit fa63833

Browse files
committed
Reorder post hooks and execute_result message
Following IPython, messages and hooks in execute_request is ordered the following way: 1. Send execute_input message if the request is not silent 2. Call pre_execute hooks 3. Call pre_run_cell hooks if the request is not silent 4. Run cell code 5. If the result is not null and the request is not silent, perform display the result and send execute_result message 6. Call post_execute hooks 7. Call post_run_cell hooks if the request is not silent 8. Send execute_reply message
1 parent 53019cc commit fa63833

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/iruby/kernel.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,17 @@ def execute_request(msg)
134134
content[:execution_count] = @execution_count
135135
end
136136

137+
unless result.nil? || silent
138+
@session.send(:publish, :execute_result,
139+
data: Display.display(result),
140+
metadata: {},
141+
execution_count: @execution_count)
142+
end
143+
137144
events.trigger(:post_execute)
138145
events.trigger(:post_run_cell, result) unless silent
139146

140147
@session.send(:reply, :execute_reply, content)
141-
@session.send(:publish, :execute_result,
142-
data: Display.display(result),
143-
metadata: {},
144-
execution_count: @execution_count) unless result.nil? || msg[:content]['silent']
145148
end
146149

147150
def error_content(e)

test/iruby/kernel_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def inspect
7070
@kernel.execute_request(msg)
7171

7272
assert_equal({
73-
msg_types: [ "execute_input", "execute_reply", "execute_result" ],
73+
msg_types: [ "execute_input", "execute_result", "execute_reply" ],
7474
execute_reply: {
7575
status: "ok",
7676
user_expressions: {},

0 commit comments

Comments
 (0)