Various issues regarding thread

Gabriel Ambuehl gabriel_ambuehl at buz.ch
Tue Mar 20 14:30:12 EST 2001


-----BEGIN PGP SIGNED MESSAGE-----

Hello,
I've been developping a small resource monitoring syste, in Python in
the
last time and got some questions regarding threading.thread. I figured
it would probably be the easiest way (forking of new processes seems
very unwise as RAM to useage) to have a dedicated thread for
every resource that has to be monitored so it would be possible to
just have them sleep between the work and let Python do the
scheduling. Now however, I thought it could be cool to have the thing
using pickle to dump its state before it exits so it could continue
its work right where it left last time (not yet sure if this makes
much sense though ;-). The only problem there is that pickle doesn't
appear to be working on lock objects which the thread subclasses
inherently got. So is there any possibility to serialize a class that
has been inherited from threading.thread?

Another thing I couldn't figure out is how one could stop a thread
reliably. I first thought one could have a flag that gets checked by
the run method every now and then but then found this to be to slow as
it could well be that a thread sleeps for several minutes before it
notices that the flag had been set and thus should have exited some
time ago. What am I overlooking?







Best regards,
 Gabriel

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.0.2i

iQEVAwUBOrehucZa2WpymlDxAQHp/AgAzVT0NZbjq3jASS36tCetRMYGunuprDCN
EsIJYgn3/lMMgVOsYyPhio+54D3pqJiEC70fTF3Oixs3COphkzODan12AhHwY/56
cB//mLfMyHkwQ3MuIYaNMGrB2gW36Dka5Fn1EJRm4jMZM1yTS9urvKR5RWiH/Q4Y
YXOJaco2RIvsay3e7f+ZgzC4zPM1hEakDs8DtS+JkXfu1rtMGA28GR1nug7JCaLH
UTDOhcv5eL/bleZKH6GxUFsTEehqQIhxJm7VLK4ODwEILG2QiDo11Xggjv3IuZfX
0lVe9zRRbt9cJiMfbJDFSfsJCBEzSZieJdZDr9tFJ0R8B0Svh0ORmQ==
=uF7d
-----END PGP SIGNATURE-----






More information about the Python-list mailing list