Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silent request fails #432

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

Silent request fails #432

rbosman opened this issue May 12, 2011 · 1 comment
Milestone

Comments

@rbosman
Copy link

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

@minrk minrk closed this as completed in 6306cb1 May 12, 2011
@minrk
Copy link
Member

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.

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants