multithreading

Bryan bryanjugglercryptographer at yahoo.com
Sun Apr 8 20:58:03 EDT 2012


Kiuhnm wrote:
> I have a decorator which takes an optional argument that tells me
> whether I should use locks.
> Maybe I could import 'threading' only if needed. If the user wants to
> use locks I'll assume that 'threading' is available on his/her system.

Use of dummy_threading might be cleaner. It has things with the same
names as the locks in real threading, and that you can create and call
just like locks, but they don't actually do anything.

> By the way, should I avoid to 'import threading' more than once?

No; threading imports like any other competent module. The tricky part
doesn't start until you actually use its facilities.

-Bryan



More information about the Python-list mailing list