Discussion:
[bottlepy] inconsistent response using bottle + Apache + mod_wsgi
Mark Luszniak
2018-01-07 07:55:26 UTC
Permalink
Disclaimer: I'm fairly new to Bottle but have 5+ years of Python
experience. I've browsed back through this group for a year or two, and not
seen anything similar to my issue, so I apologise if this has been covered
previously.

*Does bottle cache imported python modules?*

I'll take a simple stab at explaining the problem...

if I point my browser at the defined url, it might give behaviour 1, 2 or 3
(see below).
If I refresh, I'll get the same behaviour, so if I see behaviour 2, each
refresh will give behaviour 2.
if I hit the back, and then forward buttons, I'll likely see a different
behaviour, so if I was seeing 2, I might see 1 or 3
If I refresh, I'll get the same behaviour, so if I see behaviour 1 or 3,
each refresh will give the same behavior.

behaviour 1: app returns expected output

behaviour 2: app returns output from some early code that no longer exists
in my source .py files, or .pyc filles

behaviour 3: a server error relating the function linked to the route

This inconsistent behaviour has me wondering if libraries / .pyc files are
being cached - especially since behaviour 2 does not result from the
current code?

Oh, and I've done a system wide search looking for duplicates of my .py /
.pyc files; they only appear to exist in the one expected location, but I
suppose they could be being cached with a different name?

Am I missing something silly?
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mark Luszniak
2018-01-11 18:56:38 UTC
Permalink
I've seen the same behaviour with Flask.

It seems that making substantive changes to the .py modules requires a
restart of Apache.

I guess this does imply that the modules are being cached?
Post by Mark Luszniak
Disclaimer: I'm fairly new to Bottle but have 5+ years of Python
experience. I've browsed back through this group for a year or two, and not
seen anything similar to my issue, so I apologise if this has been covered
previously.
*Does bottle cache imported python modules?*
I'll take a simple stab at explaining the problem...
if I point my browser at the defined url, it might give behaviour 1, 2 or
3 (see below).
If I refresh, I'll get the same behaviour, so if I see behaviour 2, each
refresh will give behaviour 2.
if I hit the back, and then forward buttons, I'll likely see a different
behaviour, so if I was seeing 2, I might see 1 or 3
If I refresh, I'll get the same behaviour, so if I see behaviour 1 or 3,
each refresh will give the same behavior.
behaviour 1: app returns expected output
behaviour 2: app returns output from some early code that no longer exists
in my source .py files, or .pyc filles
behaviour 3: a server error relating the function linked to the route
This inconsistent behaviour has me wondering if libraries / .pyc files are
being cached - especially since behaviour 2 does not result from the
current code?
Oh, and I've done a system wide search looking for duplicates of my .py /
.pyc files; they only appear to exist in the one expected location, but I
suppose they could be being cached with a different name?
Am I missing something silly?
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
peb aryan
2018-01-12 08:10:13 UTC
Permalink
probably this is your browser. can you tell how is your app deployed?
Post by Mark Luszniak
I've seen the same behaviour with Flask.
It seems that making substantive changes to the .py modules requires a
restart of Apache.
I guess this does imply that the modules are being cached?
Post by Mark Luszniak
Disclaimer: I'm fairly new to Bottle but have 5+ years of Python
experience. I've browsed back through this group for a year or two, and not
seen anything similar to my issue, so I apologise if this has been covered
previously.
*Does bottle cache imported python modules?*
I'll take a simple stab at explaining the problem...
if I point my browser at the defined url, it might give behaviour 1, 2 or
3 (see below).
If I refresh, I'll get the same behaviour, so if I see behaviour 2, each
refresh will give behaviour 2.
if I hit the back, and then forward buttons, I'll likely see a different
behaviour, so if I was seeing 2, I might see 1 or 3
If I refresh, I'll get the same behaviour, so if I see behaviour 1 or 3,
each refresh will give the same behavior.
behaviour 1: app returns expected output
behaviour 2: app returns output from some early code that no longer
exists in my source .py files, or .pyc filles
behaviour 3: a server error relating the function linked to the route
This inconsistent behaviour has me wondering if libraries / .pyc files
are being cached - especially since behaviour 2 does not result from the
current code?
Oh, and I've done a system wide search looking for duplicates of my .py /
.pyc files; they only appear to exist in the one expected location, but I
suppose they could be being cached with a different name?
Am I missing something silly?
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.
---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marcel Hellkamp
2018-01-12 13:07:56 UTC
Permalink
Post by Mark Luszniak
*Does bottle cache imported python modules?*
No, but Python does. You are probably using an application server
(apache+mod_wsgi or nginx+uwsgi or something similar) that starts
multiple processes with multiple python interpreters. Each one loads
modules only once, probably at the time the first request arrives. This
is why you see inconsistent behavior: You are hitting different
worker-processes with different versions of your application with each
request.

Either use the built-in development server with the auto-reloading
feature enabled which can detect changes and reload the process
automatically, or continue using apache/nginx/whatever and restart after
you made changes to your application.

This is not specific to Bottle. You will see this behavior with any
modern web stack other than PHP.
--
Marcel
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...