Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64010

Re: Communicate between Python and Node.js

References <1ea934d2-d48b-4857-aa4a-f4d24a9d8552@googlegroups.com>
Date 2014-01-16 04:40 +1100
Subject Re: Communicate between Python and Node.js
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.5536.1389807613.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Jan 16, 2014 at 4:12 AM, Manish <gill.manish90@gmail.com> wrote:
> At first I thought to use the requests library to GET/POST data to node, but I googled around and it seems lots of people think TCP sockets are the way to go. I tried implementing my own using several examples I have found online. It *kind of* works. It seems like I get blocked while trying to receive data back in the recv() loop. I never reach the end. I'm not an expert in sockets/networking, but maybe I'm not wrong in guessing it is because of the non-blocking nature of Node.js ?

Do you need to use non-blocking sockets here? I think, from a quick
skim of your code, that you'd do better with a blocking socket. Tip:
Any time you have a sleep(1) call in your code, look to see if it's
doing the wrong thing. In this case, I'm pretty sure it is. Sleeping
for a second and then trying to read from a nonblocking socket seems
like a messy way to just read until you have what you want.

There's another thread happening at the moment about networking in
Python. You may find it of interest.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Communicate between Python and Node.js Manish <gill.manish90@gmail.com> - 2014-01-15 09:12 -0800
  Re: Communicate between Python and Node.js Chris Angelico <rosuav@gmail.com> - 2014-01-16 04:40 +1100

csiph-web