473,396 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Threads and sys.excepthook

Hello guys,

I have this problem and i don't know any workarounds yet. Im
implementing a DB Connection pool, which initially creates 20
connections and keep them in a dictionary. It also implements a method
for allowing external method/classes to get a connection from that pool.
he main issue is that, from a testing app, I create a loop like this to
test the pool:

import thread
import sys
import seen #this is my module

DB = seen.DBManager()

def test(name):
try :
idc,conn = DB.get_conn()
print "Thread: ",name," -- ",DB," ID: ",idc

except :
print sys.exc_info()[0]
print sys.exc_info()[1]
print "ERROR IN HERE"
return

for i in xrange(20) :
try:
name = 'THREAD' + str(i)except:
thread.start_new(test, (name,)) #(1)
except:
print 'An Exception Ocurred'
print sys.exc_info()[0]
print sys.exc_info()[1]
But when i run this code, The code works fine the first 5 times. the
rest, all i get is this:

SIZE: 20
Thread: THREAD0 -- <seen.DBManager object at 0x403ca7ec> ID: 0
SIZE: 19
Unhandled exception in thread started by
Error in sys.excepthook:

Original exception was:
Unhandled exception in thread started by
Error in sys.excepthook:

Original exception was:
Unhandled exception in thread started by
Error in sys.excepthook:

Original exception was:
Unhandled exception in thread started by
Error in sys.excepthook:

Original exception was:

And if put a time.sleep(1) after the thread.start_new(test,
(name,)) #(1) part, then it does it all perfectly.

I dont know what is causing the problem, maybe the threads are spawning
too fast? OS issues?? python issues??

Im running Gentoo GNU/Linux and Python2.4

Thanks in advance,

Jesús Rivero - (Neurogeek)
Mar 28 '06 #1
1 7937
Jesus Rivero - (Neurogeek) wrote:
Original exception was:
Unhandled exception in thread started by
Error in sys.excepthook:

Original exception was:

And if put a time.sleep(1) after the thread.start_new(test,
(name,)) #(1) part, then it does it all perfectly.


Looks like the interpreter is shutting down before all the exception
processing finishes.

-Jonathan

Mar 28 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Josh Close | last post by:
When sys.excepthook is called, type, value and traceback are passed into it. How do I get the values of traceback? I've tried printing it, but I get the memory location. I'm gussing there are...
6
by: Lunchtimemama | last post by:
Yo all, I'm getting into Python for the first time and I'm really having a blast. I've hit a bit of a snag and was wondering if someone could lend some insight. Here be the code: import sys def...
0
by: Pramod TK | last post by:
Hi, Sometimes during execution of python scripts below mentioned error string is displayed on the console. "Unhandled exception in thread started by Error in sys.excepthook: Original exception...
17
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. ...
1
by: Hari Sekhon | last post by:
I've written an except hook into a script as shown below which works well for the most part and catches exceptions. import sys def myexcepthook(type,value,tb): do something ...
0
by: Larry Bates | last post by:
I have some classes that trap hook sys.excepthook and log exceptions prior to the program exiting. This has proven to be an effective way to log what is going on with many of my "lights out"...
1
by: Hari Sekhon | last post by:
Hi, I'm wondering if anyone can please help me on figuring out a better way of doing an excepthook. I have a script which is using an excepthook to catch any uncaught exceptions - there usually...
1
by: ian | last post by:
Hi, sys.excepthook don't work if an exception come in a thread... It's normal or its a bug ? There are any tip ? look here : http://spyced.blogspot.com/2005_06_01_archive.html Thx
3
by: Sami | last post by:
Hello, I am new to Python. I tried to hook my own ExceptionPrintingFunction sys.excepthook but it does not work. This is what I wrote:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.