2

I need to receive long polling requests from a javascript client and, based on the request message, constantly poll a REST API until true is returned. Is something like eventlet with a green threading model suitable for this? If so what will be the best way to handle it?

Javascript <==long polling ==> Python Server <==simple polling==> REST API

There can be a maximum of 200 sessions in parallel from the Javascript client, but in general there will be 3-4 active at a time.

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102

3 Answers3

1

I did not see a reason stated against using web sockets.. so I'll link this comparison between long polling and websockets

In what situations would AJAX long/short polling be preferred over HTML5 WebSockets?

There's a ton of existing libraries you can use for both python and js for this type of communication.

(my vote is for websockets)

Edit:
Some libs to consider:
http://socket.io/
https://pypi.python.org/pypi/websockets

Community
  • 1
  • 1
dcbarans
  • 482
  • 7
  • 14
  • Hey, thanks for the reply. But my question is not regarding websockets vs long polling. We already have some websocket connections open on our website hence want to avoid more. My main query is which python framework to use to handle the incoming websocket/long polling connection, poll another server and when the result is received send it back to the client. – user3518471 Jan 18 '16 at 19:12
1

It is only matter of taste - 200 sessions (even all active) it is not a challenge either for Tornado, aiohttp, gevent. I personally prefer Tornado and aiohttp over gevent, Twisted...

kwarunek
  • 12,141
  • 4
  • 43
  • 48
0

For given requirements, you can use absolutely any library/framework and any choice will be fine. You can even use OS threads and not feel any downsides. What matters here is which tool your team knows better.

temoto
  • 5,394
  • 3
  • 34
  • 50