[Python-ideas] pool threads

Kristján Valur Jónsson kristjan at ccpgames.com
Wed Nov 10 03:52:00 CET 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20101110/7eeb9cdb/attachment.html>


More information about the Python-ideas mailing list