473,569 Members | 2,836 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing traceback

Hello,

I have built a server application. It's multithreaded, and everything
works fine so far. I have only one issue with catching exceptions
after I read the documentation but I can't find any problems yet. I'm
catching all errors throughout the code into a function and I write
the traceback to the server log as well as the screen. That's all. I
need not to save it or anything else. The documentation said the
function (in this example catchError) should not handle exceptions
itself. How would I get around this issue given that writing to the
server log must not stop the server? In other words, the function
itself must handle and ignore any exceptions raised by itself. i.e. I
want to make sure that failing to write to the server log is ignored.

The code I have looks like this:

try:
handleClient(.. .)
except:
catchError(sys. exc_info())

def catchError(excI nfo):
print 'An error occured'
try:
fo=open(log, "w")
print_exc()
print_exc(None, fo)
fo.close()
except:
print 'Could not write to the server log'
Jul 18 '05 #1
0 1054

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

Similar topics

7
2225
by: Robin Becker | last post by:
def raise_an_error(): a = 3 b = 4 c = 0 try: a = a/c except: import sys, cgitb, traceback, inspect tbt,tbv,tb = sys.exc_info() print 'traceback\n',''.join(traceback.format_exception(tbt,tbv,tb))
4
1898
by: Crypt Keeper | last post by:
I am trying to write a program that asks user for several input items, then takes those items into a class that will manipulate the data and then return a line of output. I am able to input the reuired information, but it's the in-class processing and output line that keeps messing up somehow. I have tried tinkering and tweaking but with no...
1
2540
by: Thomas Guettler | last post by:
Hi, the line numbers of inspect.getinnerframes are different from traceback.format_exception. This results in wrong lines being shown in cgitb. An example is below. I looked at the source of both methods. One uses f_lineno (wrong)
5
6001
by: Fernando Perez | last post by:
Hi all, by reading through the docs, the func_closure attribute of function objects is listed as writable. Yet, nowhere does it say _how_ to write to it. I am trying to do a run-time modification of a function's closure, where I want to modify the value of one of the variables in the closure. But the closure appears as a tuple of 'cell'...
8
1989
by: gregpinero | last post by:
I'm running code via the "exec in context" statement within a much larger program. What I would like to do is capture any possible errors and show a pretty traceback just like the Python interactive interpreter does, but only show the part of the traceback relating to the code sent to exec. For example here is the code I'm using: try:...
1
2005
by: Sami Vaisanen | last post by:
This is becoming utterly painful process.... I found out that the return value from "format_exception" function is NOT a list, i.e. PyList_Check() fails. PySequence_Check() succeeds but then PySequence_List() gives me back -1. So wtf? I must say the API is crap on this part. Im trying to get error information regarding previous error and if...
3
1527
by: koutoo | last post by:
I have a code that writes to 2 seperate files. I keep getting a "list index out of range" error. The strange part is that when checking the files that I'm writing too, the script has already iterated through and finished writing, yet the error stated implies that it hasn't? So how can it be, that my script has written to the files, yet the...
0
1348
by: Gabriel Genellina | last post by:
En Mon, 26 May 2008 05:31:27 -0300, <Dominique.Holzwarth@ch.delarue.comescribió: Don't inherit from Exception - you should be able to log *any* exception, not only this specific one, I presume? print_exc writes "the exception currently being handled", not the one you're creating right now. Put the code above into your exception handler: ...
3
8381
by: amungen | last post by:
I am getting the following error from my code: Traceback (most recent call last): File "<pyshell#309>", line 1, in <module> get_handles('Python26') File "C:\Python26\e__handle.py", line 19, in get_handles ctypes.windll.user32.EnumWindows(ctypes.c_long(function),ctypes.byref(ctypes.c_char_p(arg))) WindowsError: exception: access...
0
7922
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7668
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6281
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5218
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.