Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Combing Medusa's Hair... (Design Pattern) (http://www.velocityreviews.com/forums/t740156-combing-medusas-hair-design-pattern.html)

kirby.urner@gmail.com 12-14-2010 11:34 PM

Combing Medusa's Hair... (Design Pattern)
 

This is an idea I got thinking about COM objects, and getting
some support from Mark Hammond, Python's Win32 wizard.

The goal is to have a host language (not Python) instantiate
an object that runs against the Python interpreter, which lives
as its own process. The VMs have various ways of implementing
this. Mono isn't that different right?

In this design pattern, you have something like a dry cleaner's,
where people submit jobs at the counter, and go away right
away with a ticket (Python returns -- but keeps running). When
they come back is more up to them. Work has been done in
the meantime (or not, if the queue is backed up).

So Python needs a queue in the front, to accept these job orders,
a facility for issuing tickets, and a way to catalog what tasks
are completed in some urn or receptacle (given this is Python,
we might call it a "holy grail").

The host process has a method from querying the Python object
as to whether such-and-such a job is complete or not. More
primitively, it could just check an output bin (folder) for the
expected file (perhaps each "hair" creates a PDF in roughly
1 to 4 seconds).

The reason "Medusa" is useful wordplay is it reminds us of the
asynchronous server embedded in early Zope. How Medusa
relates to Twisted is lore for others to recount. However, given
we're spawning strands, hairs or threads each time a host process
calls into our object, we're looking at a multi-snaked environment,
so the image could hardly be more apt.

The act of "combing" suggests some synchronization / communication
between threads, but that's not a requirement.

More on tap here:
http://mail.python.org/pipermail/edu...er/010141.html

Kirby

Kushal Kumaran 12-15-2010 04:10 AM

Re: Combing Medusa's Hair... (Design Pattern)
 
On Wed, Dec 15, 2010 at 5:04 AM, kirby.urner@gmail.com
<kirby.urner@gmail.com> wrote:
>
> This is an idea I got thinking about COM objects, and getting
> some support from Mark Hammond, Python's Win32 wizard.
>
> The goal is to have a host language (not Python) instantiate
> an object that runs against the Python interpreter, which lives
> as its own process. *The VMs have various ways of implementing
> this. *Mono isn't that different right?
>
> In this design pattern, you have something like a dry cleaner's,
> where people submit jobs at the counter, and go away right
> away with a ticket (Python returns -- but keeps running). *When
> they come back is more up to them. *Work has been done in
> the meantime (or not, if the queue is backed up).
>


Isn't this the way people use queuing systems (ActiveMQ and the like)?
Or simply multiprocessing + Queue.

--
regards,
kushal

kirby urner 12-15-2010 05:01 AM

Re: Combing Medusa's Hair... (Design Pattern)
 
On Tue, Dec 14, 2010 at 8:10 PM, Kushal Kumaran
<kushal.kumaran+python@gmail.com> wrote:

<< snip >>

>>
>> In this design pattern, you have something like a dry cleaner's,
>> where people submit jobs at the counter, and go away right
>> away with a ticket (Python returns -- but keeps running). *When
>> they come back is more up to them. *Work has been done in
>> the meantime (or not, if the queue is backed up).
>>

>
> Isn't this the way people use queuing systems (ActiveMQ and the like)?
> *Or simply multiprocessing + Queue.
>
> --
> regards,
> kushal
>


Yeah, that's probably right. This is more like a pedagogical
metaphor, a mnemonic. As the name for a design pattern,
it should probably be confined to Python examples, as that's
where the wordplay on Medusa makes some sense, and
not just because her hair was all snakes.

http://bytes.com/topic/python/answer...ed-medusa-zope

Kirby


All times are GMT. The time now is 06:36 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.