[Python-ideas] pool threads

Guido van Rossum guido at python.org
Wed Nov 10 05:07:51 CET 2010


Have you looked at PEP 3148?

2010/11/9 Kristján Valur Jónsson <kristjan at ccpgames.com>:
> Hi there.
>
> Occasionally you want to do something on a worker thread from Python.  Some
> operating systems, like Windows, maintain a threadpool for which you can
> queue a user work item to execute.  I was thinking that it could be a good
> idea to expose such a functionality by the thread module.
>
>
>
> With something  like:
>
>
>
> def thread.queue_call(callable, args, kwargs):
>
> #invoke the OS threadpool api and have callable called
>
>
>
>
>
> Then in threading.py:
>
> Try:
>
>   From thread import queue_call
>
> Except ImportError:
>
>   Def queue_call(callable, args, kwargs):
>
>     #default implementation
>
> Thread(target=callable, args=args, kwargs=kwargs).start()
>
>
>
>
>
> Having operating system support for this would free us from creating a new
> real thread every time such a pattern is invoked.  It would also improve the
> latency of such a call since a thread creation isn’t free.
>
>
>
> K
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
>



-- 
--Guido van Rossum (python.org/~guido)



More information about the Python-ideas mailing list