Re: Asynchronous responses example from documentation -- why import time??

Jason Harrison <[email protected]> Wed, 8 Aug 2018 13:19:23 -0700
Newsgroups gmane.comp.python.twisted.web
Message-ID <CAHVLaBHQPq6fqQ9efiYU_F1e8BCTHg_6FYrdmHQQOQJZ49UmjQ@mail.gmail.com>
--===============4611645935029179100==
Content-Type: multipart/alternative; boundary="00000000000000b47e0572f23a5a"

--00000000000000b47e0572f23a5a
Content-Type: text/plain; charset="UTF-8"

> On Wed, 8 Aug 2018 at 11:58 AM  Jean-Paul Calderone <
> [email protected]> wrote:

One possible explanation is that it has nothing to do with import time per
> se.  Instead, *any* change to your source file would have fixed the
> problem.  This could be because you had "stale" pyc files lying around
> (cached bytecode the interpreter *thought* was up-to-date with your source
> but was actually outdated).  It could also be that your server process was
> left running and was still using your old code.  Then, for some reason,
> after you added the import time your server got the new version of the code
> (perhaps you're relying on an auto-reloader and it missed a change, for
> example, or you just forgot to restart the server yourself).
>
> import time itself is definitely not a requirement for arbitrary Twisted
> Web-based programs to return a response other than 404.
>
> Jean-Paul
>
>
Hi Jean-Paul,

I made many changes to the example in order to get it to work. So perhaps
it's a caching issue, but I can't find any caches. Here's what I'm
developing on:

- OSX 10.13.6
- I'm using Sublime text, no auto reloaders afaik
- python3 --version :  Python 3.7.0
- pip3 list:

Package        Version
-------------- -------
attrs          18.1.0
Automat        0.7.0
constantly     15.1.0
dlib           19.15.0
hyperlink      18.0.0
idna           2.7
incremental    17.5.0
numpy          1.15.0
pip            18.0
PyHamcrest     1.9.0
setuptools     39.2.0
six            1.11.0
Twisted        18.7.0
wheel          0.31.1
zope.interface 4.5.0

- running the server using ./asynchronous.py
- I don't have any .pyc files in the script directory, possibly because I
"chmod +x" the source file and included the #! at the top
- I added logging and while the main program (setup of Twisted reactor)
logged, the DelayedResource class did not
- I added parts of the example at
https://twistedmatrix.com/documents/current/web/howto/web-in-60/dynamic-content.html
- I changed "resource = DelayedResource()" to "resource = ClockPage()"
- I changed the render_GET handler to return the Clock page example output
- etc until I stopped getting a 404
- I restarted the server many many times

I removed and backed out every change until I got a 404, concluding it was
the "import time" line.
Any other ideas?

--00000000000000b47e0572f23a5a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">=
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, 8 Aug 2018 at 11:=
58 AM=C2=A0=C2=A0Jean-Paul Calderone &lt;<a href=3D"mailto:exarkun@twistedm=
atrix.com">[email protected]</a>&gt; wrote:=C2=A0</blockquote><bloc=
kquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:=
1px solid rgb(204,204,204);padding-left:1ex">One possible explanation is th=
at it has nothing to do with import time per<br>
se.=C2=A0 Instead, *any* change to your source file would have fixed the<br=
>
problem.=C2=A0 This could be because you had &quot;stale&quot; pyc files ly=
ing around<br>
(cached bytecode the interpreter *thought* was up-to-date with your source<=
br>
but was actually outdated).=C2=A0 It could also be that your server process=
 was<br>
left running and was still using your old code.=C2=A0 Then, for some reason=
,<br>
after you added the import time your server got the new version of the code=
<br>
(perhaps you&#39;re relying on an auto-reloader and it missed a change, for=
<br>
example, or you just forgot to restart the server yourself).<br>
<br>
import time itself is definitely not a requirement for arbitrary Twisted<br=
>
Web-based programs to return a response other than 404.<br>
<br>
Jean-Paul<br>
<br></blockquote><div><br></div><div>Hi Jean-Paul,</div><div><br></div><div=
>I made many changes to the example in order to get it to work. So perhaps =
it&#39;s a caching issue, but I can&#39;t find any caches. Here&#39;s what =
I&#39;m developing on:</div><div><br></div><div><div class=3D"gmail_extra" =
style=3D"font-size:small;text-decoration-style:initial;text-decoration-colo=
r:initial"><div class=3D"gmail_quote"><div>- OSX 10.13.6</div><div>- I&#39;=
m using Sublime text, no auto reloaders afaik</div>- python3 --version : =
=C2=A0Python 3.7.0<br>- pip3 list:</div></div><blockquote style=3D"font-siz=
e:small;text-decoration-style:initial;text-decoration-color:initial;margin:=
0px 0px 0px 40px;border:none;padding:0px"><div class=3D"gmail_extra"><div c=
lass=3D"gmail_quote"><div><div class=3D"gmail_quote">Package=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 Version</div></div></div></div><div class=3D"gmail_extra"><di=
v class=3D"gmail_quote"><div><div class=3D"gmail_quote">-------------- ----=
---</div></div></div></div><div class=3D"gmail_extra"><div class=3D"gmail_q=
uote"><div><div class=3D"gmail_quote">attrs=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 18.1.0=C2=A0</div></div></div></div><div class=3D"gmail_extra"><div cla=
ss=3D"gmail_quote"><div><div class=3D"gmail_quote">Automat=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 0.7.0=C2=A0=C2=A0</div></div></div></div><div class=3D"gmail_ext=
ra"><div class=3D"gmail_quote"><div><div class=3D"gmail_quote">constantly=
=C2=A0 =C2=A0 =C2=A015.1.0=C2=A0</div></div></div></div><div class=3D"gmail=
_extra"><div class=3D"gmail_quote"><div><div class=3D"gmail_quote">dlib=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A019.15.0</div></div></div></div><div c=
lass=3D"gmail_extra"><div class=3D"gmail_quote"><div><div class=3D"gmail_qu=
ote">hyperlink=C2=A0 =C2=A0 =C2=A0 18.0.0=C2=A0</div></div></div></div><div=
 class=3D"gmail_extra"><div class=3D"gmail_quote"><div><div class=3D"gmail_=
quote">idna=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A02.7=C2=A0 =C2=A0=C2=A0<=
/div></div></div></div><div class=3D"gmail_extra"><div class=3D"gmail_quote=
"><div><div class=3D"gmail_quote">incremental=C2=A0 =C2=A0 17.5.0=C2=A0</di=
v></div></div></div><div class=3D"gmail_extra"><div class=3D"gmail_quote"><=
div><div class=3D"gmail_quote">numpy=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 1.15=
.0=C2=A0</div></div></div></div><div class=3D"gmail_extra"><div class=3D"gm=
ail_quote"><div><div class=3D"gmail_quote">pip=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 18.0=C2=A0 =C2=A0</div></div></div></div><div class=3D"gmail_=
extra"><div class=3D"gmail_quote"><div><div class=3D"gmail_quote">PyHamcres=
t=C2=A0 =C2=A0 =C2=A01.9.0=C2=A0=C2=A0</div></div></div></div><div class=3D=
"gmail_extra"><div class=3D"gmail_quote"><div><div class=3D"gmail_quote">se=
tuptools=C2=A0 =C2=A0 =C2=A039.2.0=C2=A0</div></div></div></div><div class=
=3D"gmail_extra"><div class=3D"gmail_quote"><div><div class=3D"gmail_quote"=
>six=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 1.11.0=C2=A0</div></div></div=
></div><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div><div clas=
s=3D"gmail_quote">Twisted=C2=A0 =C2=A0 =C2=A0 =C2=A0 18.7.0=C2=A0</div></di=
v></div></div><div class=3D"gmail_extra"><div class=3D"gmail_quote"><div><d=
iv class=3D"gmail_quote">wheel=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0.31.1=C2=
=A0</div></div></div></div><div class=3D"gmail_extra"><div class=3D"gmail_q=
uote"><div><div class=3D"gmail_quote">zope.interface 4.5.0</div></div></div=
></div></blockquote><div class=3D"gmail_extra" style=3D"font-size:small;tex=
t-decoration-style:initial;text-decoration-color:initial"><div class=3D"gma=
il_quote"><div class=3D"gmail_quote">- running the server using ./asynchron=
ous.py</div></div></div></div><div>- I don&#39;t have any .pyc files in the=
 script directory, possibly because I &quot;chmod +x&quot; the source file =
and included the #! at the top<br></div><div>- I added logging and while th=
e main program (setup of Twisted reactor) logged, the=C2=A0DelayedResource =
class did not</div><div>- I added parts of the example at=C2=A0<a href=3D"h=
ttps://twistedmatrix.com/documents/current/web/howto/web-in-60/dynamic-cont=
ent.html">https://twistedmatrix.com/documents/current/web/howto/web-in-60/d=
ynamic-content.html</a></div><div>- I changed &quot;resource =3D DelayedRes=
ource()&quot; to &quot;resource =3D ClockPage()&quot;=C2=A0</div><div>- I c=
hanged the render_GET handler to return the Clock page example output</div>=
<div>- etc until I stopped getting a 404</div><div>- I restarted the server=
 many many times</div><div><br></div></div></div><div class=3D"gmail_extra"=
><div class=3D"gmail_quote"><div>I removed and backed out every change unti=
l I got a 404, concluding it was the &quot;import time&quot; line.=C2=A0</d=
iv><div>Any other ideas?=C2=A0</div></div></div></div>

--00000000000000b47e0572f23a5a--

--===============4611645935029179100==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KVHdpc3RlZC13
ZWIgbWFpbGluZyBsaXN0ClR3aXN0ZWQtd2ViQHR3aXN0ZWRtYXRyaXguY29tCmh0dHBzOi8vdHdp
c3RlZG1hdHJpeC5jb20vY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL3R3aXN0ZWQtd2ViCg==

--===============4611645935029179100==--