[Python-ideas] @run_as_thread decorator
solipsis at pitrou.net
Sat Mar 5 20:44:16 CET 2011
Le samedi 05 mars 2011 à 11:36 -0800, geremy condra a écrit :
> 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.
Sure... My point is that the stdlib shouldn't really encourage this,
especially when it doesn't subtantially reduce typing.
This proposal seems similar in principle to the proposal of having
"implicit" asynchronous function calls without writing "yield", which
has also been shot down several times.
More information about the Python-ideas