Threading legality/morality

Syver Enstad syver at NOSPAMcyberwatcher.com
Tue Mar 27 06:43:02 EST 2001


"Aahz Maruch" <aahz at panix.com> wrote:
> Syver Enstad <syver at NOSPAMcyberwatcher.com> wrote:
> >
> >How is calling print from more than one thread looked upon?
>
> Depends what you're trying to do.  If it's debugging output and if you
> concatenate strings before trying to do a print (don't use multiple
> prints in succession), you're safe.  Anything other than that is
> probably risky -- but unlikely to do actual damage (you'll just get
> messed up output).

Yes, that is to be expected. Are you aware of any material on which Python
modules that are threadsafe, and the definition of threadsafety I am talking
about is using functions and objects from the same class in different
threads, but not one object from more than one thread. To those familiar
with COM, threadsafe like apartment threaded objects.

I have seen some strange behaviour in some multi threaded programs I have
made in python, where they seem to lockup, but a push on the the return key
(or another key, I don't know) keeps them going. These are console programs,
running under Win2000 server and professional, Python 2.0.

As I was writing this I checked out my program that has been running for
about 24 hours, downloading files from the internet via urllib, and using
ADO via pythoncom. It has been running ever so happily until about 10 clock
this morning when I inspected some output it had given. Then it froze for
about three hours, when I pushed a key on the keyboard it continued again.
Strange.





More information about the Python-list mailing list