[Python-Dev] [PEP 3148] futures - execute computations asynchronously (original) (raw)
Brian Quinlan brian at sweetapp.com
Wed Mar 10 09:19:42 CET 2010
- Previous message: [Python-Dev] [PEP 3148] futures - execute computations asynchronously
- Next message: [Python-Dev] [PEP 3148] futures - execute computations asynchronously
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 9 Mar 2010, at 08:11, exarkun at twistedmatrix.com wrote:
On 08:56 pm, digitalxero at gmail.com wrote:
On Mon, Mar 8, 2010 at 12:04 PM, Dj Gilcrease <digitalxero at gmail.com> wrote:
A style I have used in my own code in the past is a Singleton class with register and create methods, where the register takes a name(string) and the class and the create method takes the name and *args, **kwargs and acts as a factory.
So I decided to play with this design a little and since I made it a singleton I decided to place all the thread/process tracking and exit handle code in it instead of having the odd semi-global scoped shutdown, threadreferences, removedeadthreadreferences and pythonexit objects floating around in each executor file, seems to work well. The API would be from concurrent.futures import executors executor = executors.create(NAME, *args, **kwargs) # NAME is 'process' or 'thread' by default To create your own executor you create your executor class and add the following at the end Getting rid of the process-global state like this simplifies testing (both testing of the executors themselves and of application code which uses them). It also eliminates the unpleasant interpreter shutdown/module globals interactions that have plagued a number of stdlib systems that keep global state.
I'm not sure what you mean, could you clarify?
Cheers, Brian
- Previous message: [Python-Dev] [PEP 3148] futures - execute computations asynchronously
- Next message: [Python-Dev] [PEP 3148] futures - execute computations asynchronously
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]