[Tutor] Threads.... Unhandle my Exception you Feind! (fwd)
Daniel Yoo
dyoo@hkn.eecs.berkeley.edu
Thu, 14 Jun 2001 08:01:23 -0700 (PDT)
Hiya kormag,
Let me forward this to the other people on tutor. I've never used TWIG,
so I'm inclined to suspect it. *grin*
---------- Forwarded message ----------
Date: Thu, 14 Jun 2001 08:27:48 -0700 (PDT)
From: kromag@nsacom.net
To: Daniel Yoo <dyoo@hkn.eecs.berkeley.edu>,
Daniel Yoo <dyoo@hkn.eecs.berkeley.edu>, kromag@nsacom.net
Cc: tutor@python.org
Subject: Re: [Tutor] Threads.... Unhandle my Exception you Feind!
Daniel Yoo <dyoo@hkn.eecs.berkeley.edu> said:
> > But, but, but..... Really! I am looking at the code I pasted in! It has
> > double backslashes! What manner of madness? Surely your mail agent
doesn't
> > parse them into links? Anyway, I tried it with the r"pathtofile" method
> > and got the same error:
>
>
> Strange! Now I'm really confused. I'm using Pine as my email program,
> which I don't think does any email preprocessing. My apologies for my
> earlier message; I didn't realize the messages were being mangled. Sorry
> about the confusion there. What kind of email program are you using?
>
I post to this list using TWIG (a web interface that in this instance uses
perl, PHP and apache w/ssl on OpenBSD. Nice interface and fairly secure for
webmail.)
>
> > >pythonw -u dbwrong.py
> > Unhandled exception in thread:
> > Traceback (most recent call last):
> > File "dbwrong.py", line 15, in write
> > db.Execute("insert into data values(%f, '%s')" % inputtage)
> > AttributeError: 'None' object has no attribute 'Execute'
> > >Exit code: 0
>
> The assumption I'm working on is that 'db' itself is None. If you could
> add the line:
>
> ###
> if db == none:
> print "We didn't get the database connection yet."
Oho!
> ###
>
> right before the Execute, that will help test this guess. I'm focusing on
> the engine.OpenDatabase() call earlier, because that's where 'db' is being
> initialized.
>
Aha!
I smell a rat! Here again is the script with your mods and the output:
----------begin dbwrong.py--------------
import win32com.client
import random
import time
import string
import thread
engine=win32com.client.Dispatch("DAO.DBEngine.35")
db=engine.OpenDatabase(r"windowsdesktopterror.mdb")
## Function write() writes a list to the database
def write(inputtage):
if db==None:
print 'el vomito'
db.Execute("insert into data values(%f, '%s')" % inputtage)
return 'ok'
if __name__=='__main__':
tik_tok=time.time()
surprize=random.choice(['Hellbilly', 'Crunchy Tack', 'Feeble'])
the_madness=(tik_tok, surprize)
thread.start_new_thread(write,(the_madness,))
--------------end dbwrong.py----------------
and the errors:
---------begin error------------------------
>pythonw -u dbwrong.py
el vomito ## There you are you rascal!
Unhandled exception in thread:
Traceback (most recent call last):
File "dbwrong.py", line 15, in write
db.Execute("insert into data values(%f, '%s')" % inputtage)
AttributeError: 'None' object has no attribute 'Execute'
>Exit code: 0
---------end error-------------------------
> Don't worry about it. My head is starting to spin too... *grin* Again,
> sorry about the bad advice earlier. I have to learn to be more careful
> when I'm reading messages.
My orbital migrane platforms are trained upon you now. Soon you will learn to
trifle with..... Man, I really need a good mad scientist name.
>
> You may want to talk with the people on the db-sig a bit more; it sounds
> like they have good experience with the Jet database stuff. Good luck to
> you!
>
I shall! It just seems durn weird that adding a single thread causes the
database name to be spat out. Weird, man. I will post any solution.
d
>