Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43586

Threadpool item mailboxes design problem

Path csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <charleshixsn@earthlink.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'dynamically': 0.07; 'suppose': 0.07; 'feasible.': 0.09; 'instances.': 0.09; 'keys,': 0.09; 'subject:design': 0.09; 'thread': 0.14; 'actors': 0.16; 'charles': 0.16; 'dict': 0.16; 'instances,': 0.16; 'loops': 0.16; 'mean,': 0.16; 'message-id:@earthlink.net': 0.16; 'receive.': 0.16; 'received:dsl.mindspring.com': 0.16; 'subject:item': 0.16; 'else,': 0.19; 'implementing': 0.19; 'header:User-Agent:1': 0.23; 'instance,': 0.24; 'lets': 0.24; 'subject:problem': 0.24; 'sort': 0.25; "i've": 0.25; 'possibly': 0.26; 'post': 0.26; 'external': 0.29; 'database,': 0.30; "i'm": 0.30; 'continually': 0.31; 'stuff': 0.32; 'quite': 0.32; 'running': 0.33; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'too': 0.37; 'implement': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'list,': 0.38; 'planning': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'enough': 0.39; 'space': 0.40; 'even': 0.60; 'read': 0.60; 'maximum': 0.63; 'mailbox': 0.68; 'awhile': 0.84; 'dict.': 0.84; 'or...': 0.84; 'uncertain': 0.84
Date Sun, 14 Apr 2013 16:12:11 -0700
From Charles Hixson <charleshixsn@earthlink.net>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12
MIME-Version 1.0
To python-list@python.org
Subject Threadpool item mailboxes design problem
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.609.1365981993.3114.python-list@python.org> (permalink)
Lines 30
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1365981993 news.xs4all.nl 2583 [2001:888:2000:d::a6]:39214
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43586

Show key headers only | View raw


What is the best approach to implementing actors that accept and post 
messages (and have no other external contacts).

So far what I've come up with is something like:
actors     = {}
mailboxs = {}

Stuff actors with actor instances, mailboxes with multiprocessing.queue 
instances.   (Actors and mailboxes will have identical keys, which are 
id#, but it's got to be a dict rather than a list, because too many are 
rolled out to disk.)  And I'm planning of having the actors running 
simultaneously and continually in a threadpool that just loops through 
the actors that are assigned to each thread of the pool.

This lets any actor post messages to the mailbox of any other actor that 
it has the id of, and lets him read his own mail without 
multi-processing clashes.  But I'm quite uncertain that this is the best 
way, because, if nothing else, it means that each mailbox needs to be 
allocated large enough to handle the maximum amount of mail it could 
possibly receive.  (I suppose I could implement some sort of "wait 
awhile and try again" method.)  It would, however, be better if the 
mailbox could be specific to the threadpool instance, so less space 
would be wasted.  Or if the queues could dynamically resize.  Or if 
there was a threadsafe dict.  Or...  But I don't know that any of these 
are feasible.  (I mean, yes, I could write all the mail to a database, 
but is that a better answer, or even a good one?)

-- 
Charles Hixson

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Threadpool item mailboxes design problem Charles Hixson <charleshixsn@earthlink.net> - 2013-04-14 16:12 -0700
  Re: Threadpool item mailboxes design problem 88888 Dihedral <dihedral88888@googlemail.com> - 2013-04-14 19:41 -0700
  Re: Threadpool item mailboxes design problem 88888 Dihedral <dihedral88888@googlemail.com> - 2013-04-14 19:41 -0700

csiph-web