Problem with threads and signals

Holger Joukl Holger.Joukl at LBBW.de
Wed Mar 17 10:28:25 EST 2004


Sebastian wrote:
> Please post the relevant code.
the shutdown function does not get called, it seems the signal gets lost

the threads shutdown function looks like:

--- CODE ---
# self._done is a threading.Event object
def shutdown(self):
    self._done.set()

> Btw, I am new to python2.x (not new to python, though). This is not
working
> code,
> is it?
> threads = {}
> threads["dircheck"] = TimedDirectoryCheck("/tmp/dpf/notify")
> threads["process"] = BatchProcessor()
> # start the threads
> for th in threads:
>     th.start()  # <---- Does that work???
>
of cource does this work, ... makes life a lot easier and saves up
variable names ... :-))

Sebastian

Do you run C extensions in your threads?
If you code the threading objects as dummies (while loops that do nothing
but e.g. sleep for a second),
does the signal handler shutdown function get called then?
Please post a small non-working code example.

>>> class foo:
...     def do(self):
...             print "do!"
...
>>> d = {}
>>> d["f1"] = foo()
>>> d["f2"] = foo()
>>> for x in d:
...     print x
...     x.do()
...
f1
Traceback (most recent call last):
  File "<stdin>", line 3, in ?
AttributeError: 'str' object has no attribute 'do'

So what am I missing here, compared to your code?
_________________________________

Holger Joukl
Landesbank Baden-Württemberg
1651 Financial Markets Technologies
fon +49 (711) 124 - 7078
fax +49 (711) 124 - 3759
_________________________________

Der Inhalt dieser E-Mail ist vertraulich. Falls Sie nicht der angegebene
Empfänger sind oder falls diese E-Mail irrtümlich an Sie adressiert wurde,
verständigen Sie bitte den Absender sofort und löschen Sie die E-Mail
sodann. Das unerlaubte Kopieren sowie die unbefugte Übermittlung sind nicht
gestattet. Die Sicherheit von Übermittlungen per E-Mail kann nicht
garantiert werden. Falls Sie eine Bestätigung wünschen, fordern Sie bitte
den Inhalt der E-Mail als Hardcopy an.

The contents of this  e-mail are confidential. If you are not the named
addressee or if this transmission has been addressed to you in error,
please notify the sender immediately and then delete this e-mail.  Any
unauthorized copying and transmission is forbidden. E-Mail transmission
cannot be guaranteed to be secure. If verification is required, please
request a hard copy version.







More information about the Python-list mailing list