Re: How to implement a cherrypy server with long-polling enabled path?

北美38fule <[email protected]> Thu, 19 Dec 2019 10:49:51 -0800 (PST)
Newsgroups gmane.comp.python.cherrypy
Message-ID <[email protected]>
------=_Part_490_34294268.1576781391382
Content-Type: multipart/alternative; 
	boundary="----=_Part_491_1916760755.1576781391382"

------=_Part_491_1916760755.1576781391382
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Thanks for your suggestion. I've read some articles saying that websocket=
=20
would be an overkill. My application doesn't require high frequency=20
bi-directional communications. It's only occasionally needs some updates=20
from backend. So I'm reluctant to adopt websocket in my use case.

On Wednesday, December 18, 2019 at 8:54:33 PM UTC-8, Tim Roberts wrote:
>
> On Dec 17, 2019, at 6:23 PM, =E5=8C=97=E7=BE=8E38fule <38fule.no...@gmail=
.com=20
> <javascript:>> wrote:=20
> >=20
> > I am a newbie in cherrypy. I've done some research on google but didn't=
=20
> get much helpful information.=20
> > Could someone please point out if cherrypy allows me to write a simple=
=20
> server that has long-polling enabled path?=20
> > The scenario is like: whenever the database on backend has some updated=
=20
> information, it sends signals to the frontend to updates all relevant=20
> display accordingly.=20
> >=20
> > Is this achievable using cherrypy? Or I will need tornado-like=20
> framework? Could someone also point out a newbie-friendly tutorial for th=
is=20
> purpose? Thanks.=20
>
> That=E2=80=99s just not how HTTP works.  The right way to do this is =E2=
=80=9Cpull model=E2=80=9D:=20
>  have the clients (that is, the browsers) poll for the new data.  It=E2=
=80=99s=20
> possible to use WebSockets to set up a persistent connection to a server,=
=20
> but you=E2=80=99d want another TCP server, not an HTTP server.  HTTP is f=
ire and=20
> forget.  One request, one response, close the socket.=20
>
> General TCP servers are basically trivial to write in Python.=20
> =E2=80=94=20
> Tim Roberts, [email protected] <javascript:>=20
> Providenza & Boekelheide, Inc.=20
>
>

--=20
You received this message because you are subscribed to the Google Groups "=
cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To view this discussion on the web visit https://groups.google.com/d/msgid/=
cherrypy-users/c26ef072-edc0-4307-a414-fa30a97d19e3%40googlegroups.com.

------=_Part_491_1916760755.1576781391382
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thanks for your suggestion. I&#39;ve read some articles sa=
ying that websocket would be an overkill. My application doesn&#39;t requir=
e high frequency bi-directional communications. It&#39;s only occasionally =
needs some updates from backend. So I&#39;m reluctant to adopt websocket in=
 my use case.<br><br>On Wednesday, December 18, 2019 at 8:54:33 PM UTC-8, T=
im Roberts wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On Dec 17, 20=
19, at 6:23 PM, =E5=8C=97=E7=BE=8E38fule &lt;<a href=3D"javascript:" target=
=3D"_blank" gdf-obfuscated-mailto=3D"mNm9RJNZAAAJ" rel=3D"nofollow" onmouse=
down=3D"this.href=3D&#39;javascript:&#39;;return true;" onclick=3D"this.hre=
f=3D&#39;javascript:&#39;;return true;">38fule.no...@gmail.<wbr>com</a>&gt;=
 wrote:
<br>&gt;=20
<br>&gt; I am a newbie in cherrypy. I&#39;ve done some research on google b=
ut didn&#39;t get much helpful information.
<br>&gt; Could someone please point out if cherrypy allows me to write a si=
mple server that has long-polling enabled path?
<br>&gt; The scenario is like: whenever the database on backend has some up=
dated information, it sends signals to the frontend to updates all relevant=
 display accordingly.
<br>&gt;=20
<br>&gt; Is this achievable using cherrypy? Or I will need tornado-like fra=
mework? Could someone also point out a newbie-friendly tutorial for this pu=
rpose? Thanks.
<br>
<br>That=E2=80=99s just not how HTTP works. =C2=A0The right way to do this =
is =E2=80=9Cpull model=E2=80=9D: =C2=A0have the clients (that is, the brows=
ers) poll for the new data. =C2=A0It=E2=80=99s possible to use WebSockets t=
o set up a persistent connection to a server, but you=E2=80=99d want anothe=
r TCP server, not an HTTP server. =C2=A0HTTP is fire and forget. =C2=A0One =
request, one response, close the socket.
<br>
<br>General TCP servers are basically trivial to write in Python.
<br>=E2=80=94=20
<br>Tim Roberts, <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-m=
ailto=3D"mNm9RJNZAAAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;jav=
ascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;re=
turn true;">[email protected]</a>
<br>Providenza &amp; Boekelheide, Inc.
<br>
<br></blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;cherrypy-users&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:cherrypy-users+unsubscribe-/[email protected]">cher=
rypy-users+unsubscribe-/[email protected]</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/d/msgid/cherrypy-users/c26ef072-edc0-4307-a414-fa30a97d19e3%40googlegrou=
ps.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/=
msgid/cherrypy-users/c26ef072-edc0-4307-a414-fa30a97d19e3%40googlegroups.co=
m</a>.<br />

------=_Part_491_1916760755.1576781391382--

------=_Part_490_34294268.1576781391382--