473,624 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Howto pass exceptions between threads

Hallo Alltogether,

I've searched in this mailing list, but it seems to me that there is no general
approach to pass exceptions from one thread to another.

I think most application do a unique way of handling "unhandled exceptions", at
least they (should) try to log them.

The following discussion seems to me most valuable (Sorry for the long URL, I
don't know a way of shorter)

http://groups.google.de/group/comp.l...820c20ff3fcea8
http://groups.google.de/group/comp.l...8a8d9e85883fe3

I've the feeling that if you're using the python class threading.Threa d you've a
unique interface of handling it. (thread synchronizing + exception raising)

But' when you've a C++ extension, that uses it's own thread implementation and
your exceptions happens in python code (but from a thread that is controlled by
your extension) you have another problem.

Maybe I've overseen something in the python docu, so I ask for the solutions,
concepts, hints ... you solved the problem.

Regards
Alexander
Mar 5 '07 #1
2 2102
Alexander Eisenhuth wrote:
Hallo Alltogether,

I've searched in this mailing list, but it seems to me that there is no
general approach to pass exceptions from one thread to another.
Very few languages have that.

Actually, it could be made to work for Python, but it would have to
be carefully designed. Something that raises an exception in another
thread the next time the thread blocks would have relatively sane
semantics. You couldn't raise an exception on a compute-bound thread,
only at block points (locks, I/O, long system calls.)

John Nagle
Mar 5 '07 #2
John Nagle schrieb:
Alexander Eisenhuth wrote:
>Hallo Alltogether,

I've searched in this mailing list, but it seems to me that there is
no general approach to pass exceptions from one thread to another.

Very few languages have that.

Actually, it could be made to work for Python, but it would have to
be carefully designed. Something that raises an exception in another
thread the next time the thread blocks would have relatively sane
semantics. You couldn't raise an exception on a compute-bound thread,
only at block points (locks, I/O, long system calls.)

John Nagle
Yes you're right, it must be well designed with a clear responsibility
delegation. I can imgagine the following points:

- Thread termination with termination handler (for Thread instance)
- Main Thread information / synchronisation
- Default/Customized main thread exception handler
Mar 6 '07 #3

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

Similar topics

1
1711
by: Roy Smith | last post by:
What is supposed to happen when an exception is raised and not caught in a thread? The Reference Manual (section 4.2) states "When an exception is not handled at all, the interpreter terminates execution of the program, or returns to its interactive main loop", but it looks like what really happens is the thread is terminated, not the whole program. If I run the following: ------- #!/usr/bin/env python
33
2985
by: Steven Bethard | last post by:
I feel like this has probably been answered before, but I couldn't find something quite like it in the archives. Feel free to point me somewhere if you know where this has already been answered. I have a list in a particular order that I want to split into two lists: the list of every nth item, and the list of remaining items. It's important to maintain the original order in both lists. So the first list is simple:
8
3578
by: Shane Groff | last post by:
I know this is a recurring discussion (I've spent the last 3 days reading through threads on the topic), but I feel compelled to start it up again. After reading through the existing threads, I find myself convinced that exceptions are a better mechanism, for example because constructors and operators can't return errors, and code that doesn't need to handle/translate/recover in the face of errors, but can just propagate the error is...
16
2159
by: Einar Høst | last post by:
Hi, I'm getting into the Trace-functionality in .NET, using it to provide some much-needed logging across dlls in the project we're working on. However, being a newbie, I'm wondering if some more experienced loggers can provide me with some ideas as to how to log in a simple yet flexible manner. For instance, I'd like the code to be as uncluttered as possible by Trace statements. As an example of basic logging functionality, I've come...
3
11576
by: Sako | last post by:
I am trying to teach myself perl by writing a program I've been meaning to implement, so I am pretty green in perl. I'm having problems sharing filehandles opened by a thread - been RTFM for a few days, but am having no luck. I am attempting to write a threaded server program that listens on a socket for requests, then passes the socket's filehandle to an event processor routine, while the listener thread keeps on listening. However, I...
6
2355
by: robert | last post by:
I get python crashes and (in better cases) strange Python exceptions when (in most cases) importing and using cookielib lazy on demand in a thread. It is mainly with cookielib, but remember the problem also with other imports (e.g. urllib2 etc.). And again very often in all these cases where I get weired Python exceptions, the problem is around re-functions - usually during re.compile calls during import (see some of the exceptions below). But...
6
2488
by: Pieter | last post by:
Hi, For some procedures that throws exceptions, I would like to show different messages to the user depending on what type of exception he's getting. For instance this one: when the file is locked, I want a messagebox to tell that the user has to close the file first. Is there a way to identify an exception by some kind of unique number or something like this? I don't want to identify it on the Exception Message because some users are...
2
2039
by: james | last post by:
Hi all, I have a console app that uses AppDomain.CurrentDomain.UnhandledException. However it only seems to catch exceptions in the current thread. Exceptions in other threads (like from a timer) don't seem to get reported at all (and my application keeps running). How do I catch unhandled exceptions in other threads? -James
0
8234
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8172
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8677
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8335
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7158
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6110
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5563
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4079
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.