[Python-ideas] @run_as_thread decorator

Nick Coghlan ncoghlan at gmail.com
Sun Mar 6 01:55:11 CET 2011


On Sun, Mar 6, 2011 at 3:16 AM, Jesse Noller <jnoller at gmail.com> wrote:
> I've long wanted to put something into the stdlib like this, but as
> others in the thread have pointed out - there's some semantics that
> remain to be hashed out and the behavior is dangerous (imo), and
> magical to have in the stdlib right now.
>
> In this case, I would recommend building out a library that contains
> these decorators (both threads and processes) building from the
> futures (concurrent.futures.Executor ABC) library as possible, and
> let's see how it pans out. I've struggled with really liking/wanting
> this and the fact that it's dangerous, and surprising.

Well said, especially the last line :)

However, I suspect this is one of those things where:
- rewriting it yourself is easier than finding a library for it, so a
PyPI module would gather little interest or feedback
- doing it "right" in the stdlib would eliminate the temptation to
develop custom not-quite-right implementations (e.g. ones where the
decorator actually *creates* and starts the thread)

It would make a good topic for a PEP, IMO.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list