[Python-ideas] @run_as_thread decorator

geremy condra debatem1 at gmail.com
Sat Mar 5 20:36:25 CET 2011

On Sat, Mar 5, 2011 at 11:31 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> Le samedi 05 mars 2011 à 20:25 +0100, Giampaolo Rodolà a écrit :
>> from utils import run_as_thread
>> class Admin:
>>     @run_as_thread
>>     def refresh_persons(self):
>>         ...
> That strikes me as a bad idea, because another module or library calling
> refresh_persons() has no clue that this implictly starts a separate
> thread (instead of being a "normal" method).

I just don't really find this that convincing; you're calling the
function, you should probably know what it does. That's doubly true in
this case, since you have to code around the fact that it's working in
a separate thread if you want to use the return value.

Geremy Condra

More information about the Python-ideas mailing list