Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'dynamically': 0.07; 'suppose': 0.07; 'feasible.': 0.09; 'instances.': 0.09; 'keys,': 0.09; 'subject:design': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.11; 'thread': 0.14; 'actors': 0.16; 'charles': 0.16; 'dict': 0.16; 'instances,': 0.16; 'loops': 0.16; 'mean,': 0.16; 'receive.': 0.16; 'subject:item': 0.16; 'else,': 0.19; 'implementing': 0.19; 'cc:addr:python.org': 0.22; 'header :User-Agent:1': 0.23; 'instance,': 0.24; 'lets': 0.24; 'subject:problem': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'sort': 0.25; "i've": 0.25; 'possibly': 0.26; 'post': 0.26; 'required.': 0.27; 'header:In-Reply-To:1': 0.27; '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; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'something': 0.35; 'operations': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'too': 0.37; 'received:209': 0.37; 'implement': 0.38; 'actions': 0.38; 'from:addr:googlemail.com': 0.38; 'handle': 0.38; 'list,': 0.38; 'planning': 0.38; 'rather': 0.38; 'enough': 0.39; 'space': 0.40; 'even': 0.60; 'read': 0.60; 'new': 0.61; 'maximum': 0.63; 'more': 0.64; 'mailbox': 0.68; 'receive': 0.70; 'gain': 0.79; 'awhile': 0.84; 'dict.': 0.84; 'or...': 0.84; 'uncertain': 0.84 X-Received: by 10.50.131.232 with SMTP id op8mr625421igb.5.1365993699488; Sun, 14 Apr 2013 19:41:39 -0700 (PDT) Newsgroups: comp.lang.python Date: Sun, 14 Apr 2013 19:41:39 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=123.192.32.215; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw References: User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 123.192.32.215 MIME-Version: 1.0 Subject: Re: Threadpool item mailboxes design problem From: 88888 Dihedral To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 75 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365993702 news.xs4all.nl 2587 [2001:888:2000:d::a6]:54973 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43600 Charles Hixson=E6=96=BC 2013=E5=B9=B44=E6=9C=8815=E6=97=A5=E6=98=9F=E6=9C= =9F=E4=B8=80UTC+8=E4=B8=8A=E5=8D=887=E6=99=8212=E5=88=8611=E7=A7=92=E5=AF= =AB=E9=81=93=EF=BC=9A > What is the best approach to implementing actors that accept and post=20 >=20 > messages (and have no other external contacts). >=20 >=20 >=20 > So far what I've come up with is something like: >=20 > actors =3D {} >=20 > mailboxs =3D {} >=20 >=20 >=20 > Stuff actors with actor instances, mailboxes with multiprocessing.queue= =20 >=20 > instances. (Actors and mailboxes will have identical keys, which are=20 >=20 > id#, but it's got to be a dict rather than a list, because too many are= =20 >=20 > rolled out to disk.) And I'm planning of having the actors running=20 >=20 > simultaneously and continually in a threadpool that just loops through=20 >=20 > the actors that are assigned to each thread of the pool. >=20 >=20 >=20 > This lets any actor post messages to the mailbox of any other actor that= =20 >=20 > it has the id of, and lets him read his own mail without=20 >=20 > multi-processing clashes. But I'm quite uncertain that this is the best= =20 >=20 > way, because, if nothing else, it means that each mailbox needs to be=20 >=20 > allocated large enough to handle the maximum amount of mail it could=20 >=20 > possibly receive. (I suppose I could implement some sort of "wait=20 >=20 > awhile and try again" method.) It would, however, be better if the=20 >=20 > mailbox could be specific to the threadpool instance, so less space=20 >=20 > would be wasted. Or if the queues could dynamically resize. Or if=20 >=20 > there was a threadsafe dict. Or... But I don't know that any of these= =20 >=20 > are feasible. (I mean, yes, I could write all the mail to a database,=20 >=20 > but is that a better answer, or even a good one?) >=20 >=20 >=20 > --=20 >=20 > Charles Hixson Actors can receive and response to messages to take actions accordingly in time in one or more cores. The timer is required and the message read/write operations=20 are required. Do you want the actors to gain new methods to evolve=20 in the long run?