Skip to content
This repository

Silent request fails #432

Closed
rbosman opened this Issue May 12, 2011 · 1 comment

2 participants

rbosman Min RK
rbosman
rbosman commented May 12, 2011

Hi,

I created a script that does an execute_request to IPython via zmq. The script works fine as long as the 'silent' flag is set to False. When 'silent' is set to True, the last error seems to be replicated. To demonstrate the issue:

import zmq, json
context = zmq.Context()
socketReq = context.socket(zmq.XREQ)
socketReq.connect("tcp://127.0.0.1:8000")

def create_msg(code, silent):
  execute = {
      'code' : code,
      'silent' : silent,
      'user_variables' : [],
      'user_expressions' : {},
      }

  contents = { 'header' : 
      { 'msg_id' : 'msg', 
      'username' : 'user', 
      'session' : 'session'},
      'parent_header' : {},
      'msg_type' : 'execute_request',
      'content' : execute
      }

  return json.dumps(contents)

def get_status(message):
  val = json.loads(message)
  return val["content"]["status"]


print "Silent: False"
print "Incorrect call: error expected"
socketReq.send( create_msg("incorrect.call()", False ) )
print "GOT: ", get_status( socketReq.recv() ); 

print "Correct call: no error expected"
socketReq.send( create_msg("2 + 2", False )) 
print "GOT: ", get_status( socketReq.recv() ); 

print 
print "Silent: True"

print "Incorrect call: error expected"
socketReq.send( create_msg("incorrect.call()", True ) )
print "GOT: ", get_status( socketReq.recv() ); 

print "Correct call, no error expected"
socketReq.send( create_msg("2 + 2", True ) )
print "GOT: ", get_status( socketReq.recv() ); 

The output of the script is as follows:

Silent: False
Incorrect call: error expected
GOT:  error
Correct call: no error expected
GOT:  ok

Silent: True
Incorrect call: error expected
GOT:  error
Correct call, no error expected
GOT:  error

Is this indeed incorrect behavior, or am I doing something wrong?

Regards, Raymond

Min RK minrk closed this in 6306cb1 May 12, 2011
Min RK
Owner
minrk commented May 12, 2011

The exception info wasn't cleaned up in silent mode, so the same exception would get raised in subsequent silent calls, regardless of their success.

Should be fixed now.

Brian E. Granger ellisonbg referenced this issue from a commit January 10, 2012
Commit has since been removed from the repository and is no longer available.
Damián Avila damianavila referenced this issue from a commit July 30, 2013
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.