[Tutor] Threads.... Unhandle my Exception you Feind! (fwd)

Daniel Yoo dyoo@hkn.eecs.berkeley.edu
Thu, 14 Jun 2001 08:28:40 -0700 (PDT)


On Thu, 14 Jun 2001, Daniel Yoo wrote:
> 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,))


Let's explore the problem further.  Can you try this program?:

###
import win32com.client
import random
import time
import string

engine=win32com.client.Dispatch("DAO.DBEngine.35")
db=engine.OpenDatabase(r"windowsdesktopterror.mdb")
if db==None:
	print 'el vomito 1'


## Function write() writes a list to the database
def write(inputtage):
	if db==None:
		print 'el vomito 2'
	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)
	write(the_madness)
###

If this program says "el vomito 1', then it's definitely because of:

    db=engine.OpenDatabase(r"\\windows\\desktop\\terror.mdb")

and that's something you can fix.  Otherwise, if everything works, then it
must have something to do with way threads work.  I think I sorta
understand what's going on, but the results of this experiment will make
me more sure.  Let's try this experiment and see what we get from it.

Hope this helps!