Logging tracebacks to MySQL (was RE: hang in urllib.read()?)

Aahz aahz at pythoncraft.com
Tue Mar 26 20:09:31 EST 2002


In article <mailman.1017184602.14548.python-list at python.org>,
Nick Arnett <narnett at mccmedia.com> wrote:
>
>At this point, my robot is being nicely stable, but now I'm starting to
>think that the real problem was time-outs, but I sure don't see why they
>would last for hours.  Aahz's suggestion of using timeoutsocket was right on
>the mark.  I am definitely seeing timeouts now, which are recovering nicely
>by simply starting over with urlopen.

Sockets are simply unreliable over any kind of external network.  I've
learned to use timeout code even for internal networks, just to be safe.

>And after a fairly hideous time figuring out how to come up with an
>appropriate error message and escape it for MySQL, timeouts are now even
>being logged into a table.  If anyone has an example of getting a full
>traceback into a MySQL field, I'd be grateful to see it.  What seemingly
>should work seems to somehow recurse a few times, so that backslashes and
>such get repeatedly escaped... at least in all the ways I could see to use
>the traceback module.  I gave up and up and I'm using sys.exc_info()[:2]
>instead, which is probably sufficient information.

You should only need to escape "'" if you're using straight SQL calls.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"We should forget about small efficiencies, about 97% of the time.
Premature optimization is the root of all evil."  --Knuth



More information about the Python-list mailing list