Skip to content

Connection becomes invalid when getting and unexisting variable #91

@dukebody

Description

@dukebody

I start a new pymatbridge server and don't define the variable 'x' in Matlab. Now I execute:

In [6]: mlab.get_variable('x')
??? Error using ==> evalin
Undefined function or variable 'x'.

Error in ==> pymat_get_variable at 27
response.var = evalin('base', varname);

Error in ==> matlabserver at 34
            resp = feval(fhandle, req);

>> 

It gets stuck, and if I press ^C I get the traceback:

KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-6-5e01d5fc1178> in <module>()
----> 1 mlab.get_variable('x')

/home/dukebody/.virtualenvs/pymatbridge/lib/python2.7/site-packages/pymatbridge/pymatbridge.pyc in get_variable(self, varname, maxtime)                                                                                                             
    225         req = json.dumps(req, cls=ComplexEncoder)
    226         self.socket.send(req)
--> 227         resp = self.socket.recv_string()
    228         resp = json.loads(resp, object_hook=as_complex)
    229 

/home/dukebody/.virtualenvs/pymatbridge/lib/python2.7/site-packages/zmq/sugar/socket.pyc in recv_string(self, flags, encoding)                                                                                                                      
    342             The Python unicode string that arrives as encoded bytes.
    343         """
--> 344         b = self.recv(flags=flags)
    345         return b.decode(encoding)
    346 

/home/dukebody/.virtualenvs/pymatbridge/lib/python2.7/site-packages/zmq/backend/cython/socket.so in zmq.backend.cython.socket.Socket.recv (zmq/backend/cython/socket.c:5787)()

/home/dukebody/.virtualenvs/pymatbridge/lib/python2.7/site-packages/zmq/backend/cython/socket.so in zmq.backend.cython.socket.Socket.recv (zmq/backend/cython/socket.c:5587)()

/home/dukebody/.virtualenvs/pymatbridge/lib/python2.7/site-packages/zmq/backend/cython/socket.so in zmq.backend.cython.socket._recv_copy (zmq/backend/cython/socket.c:1720)()

/home/dukebody/.virtualenvs/pymatbridge/lib/python2.7/site-packages/zmq/backend/cython/socket.so in zmq.backend.cython.checkrc._check_rc (zmq/backend/cython/socket.c:6037)()

Now the connection doesn't work anymore:

In [7]: mlab.get_variable('a')
---------------------------------------------------------------------------
ZMQError                                  Traceback (most recent call last)
<ipython-input-26-a3a6f8279f49> in <module>()
----> 1 mlab.get_variable('a')

/home/dukebody/.virtualenvs/pymatbridge/lib/python2.7/site-packages/pymatbridge/pymatbridge.pyc in get_variable(self, varname, maxtime)
    224         req['varname'] = varname
    225         req = json.dumps(req, cls=ComplexEncoder)
--> 226         self.socket.send(req)
    227         resp = self.socket.recv_string()
    228         resp = json.loads(resp, object_hook=as_complex)

/home/dukebody/.virtualenvs/pymatbridge/lib/python2.7/site-packages/zmq/backend/cython/socket.so in zmq.backend.cython.socket.Socket.send (zmq/backend/cython/socket.c:5449)()

/home/dukebody/.virtualenvs/pymatbridge/lib/python2.7/site-packages/zmq/backend/cython/socket.so in zmq.backend.cython.socket.Socket.send (zmq/backend/cython/socket.c:5209)()

/home/dukebody/.virtualenvs/pymatbridge/lib/python2.7/site-packages/zmq/backend/cython/socket.so in zmq.backend.cython.socket._send_copy (zmq/backend/cython/socket.c:2030)()

/home/dukebody/.virtualenvs/pymatbridge/lib/python2.7/site-packages/zmq/backend/cython/socket.so in zmq.backend.cython.checkrc._check_rc (zmq/backend/cython/socket.c:6263)()

ZMQError: Operation cannot be accomplished in current state

This is certainly not ideal. I assume that the connection gets blocked waiting for a kind of response that never arrives.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions