[IPython-dev] XREQ/XREP socets

Brian Granger ellisonbg at gmail.com
Wed Aug 31 12:54:31 EDT 2011


On Wed, Aug 31, 2011 at 8:41 AM, Sean Ross-Ross <srossross at gmail.com> wrote:
> Thanks for the response Brian, I asked about avoiding the ZeroMQ layer
> because:
>
> 1) From the documentation It looks like the sending of JSON data across
> sockets is supposed to be technology independent. I this a correct
> assumption,  or is ZMQ a hard dependency?

ZMQ is definitely a hard dependency unless you want to implement the
ZMQ framing procotol and queuing on top of raw TCP sockets.  But I
highly advise agains doing that for the following reasons:

* There are binary installers for pyzmq that include zmq for most platforms.
* With raw Python sockets You will quickly run into the limitations of
the GIL.  ZMQ does all of its send/recv/queue logic in C level threads
with the GIL released, so it doesn't have that limitation.
* ZMQ sockets "just work" so you won't have to reinvent wheel.
* Reimplementing ZMQ on top of sockets in Python will be a huge
project and maintaining it will be significant effort because ZMQ it
evolving quickly.

> 2) The javascript server already implements an asynchronous sockets layer,
> it seems like an unnecessary step to install the zmq/javascript bindings.

All ZMQ stuff is done using PyZMQ, and there is no zmq/javascript
bindings.  And all of the existing async socket layer in the notebook
server is PyZMQ based sockets, not raw sockets.

Can you describe more of what you are trying to do?

Cheers,

Brian

>
> On Aug 29, 2011, at 5:27 PM, Brian Granger wrote:
>
> IPython uses PyZMQ/ZeroMQ for its sockets, so you will need to
> download them here:
>
> https://github.com/zeromq/pyzmq
> http://www.zeromq.org/intro:get-the-software
>
> Cheers,
>
> Brian
>
> On Mon, Aug 29, 2011 at 11:18 AM, Sean Ross-Ross <srossross at gmail.com>
> wrote:
>
> Hello, I've been playing around with the new socketed API and I have a few
>
> questions.
>
> My end goal is to create a simple javascript server. But for now I'm trying
>
> to see if I understand how the sockets work.
>
> In my testing I start an ipython kernel:
>
> $ ipython qtconsole
>
> [IPKernelApp] To connect another client to this kernel, use:
>
> [IPKernelApp] --existing --shell=49785 --iopub=49786 --stdin=49787
>
> --hb=49788
>
> Then, in another terminal I try to send a command manually to the shell
>
> socket (using python):
>
> import socket
>
> import json
>
> shell_sock = socket.create_connection(('localhost',49785))
>
> header = { 'msg_id' : 'uuid-123', 'username': 'sean', 'session': '??',
>
> 'msg_type': 'connect_request', }
>
> msg = dict(parent_header=parent_header, header=header, content=content)
>
> msg_str = json.dumps(msg)
>
> shell_sock.send(msg_str)
>
> shell_sock.recv(1024**2)
>
> This does not work, and I do not get any response. Why? I would use zmq but
>
> the server is implemented in javascript.  I also can not use ajax or jquery
>
> from the client-side html notebook app because this is on the server side.
>
> Thanks in advance.
>
> ~Sean
>
> _______________________________________________
>
> IPython-dev mailing list
>
> IPython-dev at scipy.org
>
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
>
>
>
> --
> Brian E. Granger
> Cal Poly State University, San Luis Obispo
> bgranger at calpoly.edu and ellisonbg at gmail.com
>
>



-- 
Brian E. Granger
Cal Poly State University, San Luis Obispo
bgranger at calpoly.edu and ellisonbg at gmail.com



More information about the IPython-dev mailing list