Cross-process dictionary/hashtable

S

Sandra-24

A dictionary that can be shared across processes without being
marshaled?

Is there such a thing already for python?

If not is there one for C maybe?

I was just thinking how useful such a thing could be. It's a great way
to share things between processes. For example I use a cache that
subclasses a dictionary. It would be trivial to modify it to work
across processes by changing the base class and the locking mechanism.

Thanks,
-Sandra
 
C

Calvin Spealman

A dictionary that can be shared across processes without being
marshaled?

Is there such a thing already for python?

If not is there one for C maybe?

I was just thinking how useful such a thing could be. It's a great way
to share things between processes. For example I use a cache that
subclasses a dictionary. It would be trivial to modify it to work
across processes by changing the base class and the locking mechanism.

Thanks,
-Sandra

Maybe what you want is something like memcache
(http://cheeseshop.python.org/pypi/memcached), which offers a basic
in-memory, key-value share that processes (even on different boxes)
can connect to. Of course, as with any kind of concurrent work, its
going to be far easier to have some restrictions, which memcache has.
For example, full python objects being shared isn't a great idea, or
even possible in many situations. The closest you could get with
something like memcache is to wrap it up in a dictionary-like object
and have it pickle things coming in and out, but that won't work for
everying and has security concerns.
 
S

Sandra-24

I looked at posh, and read the report on it, it's very interesting, but
it will not work for me. Posh requires that it forks the processes, but
in mod_python the processes were forked by apache and use different
interpreters.

Calvin said:
Maybe what you want is something like memcache
(http://cheeseshop.python.org/pypi/memcached), which offers a basic
in-memory, key-value share that processes (even on different boxes)
can connect to. Of course, as with any kind of concurrent work, its
going to be far easier to have some restrictions, which memcache has.
For example, full python objects being shared isn't a great idea, or
even possible in many situations. The closest you could get with
something like memcache is to wrap it up in a dictionary-like object
and have it pickle things coming in and out, but that won't work for
everying and has security concerns.

Memcached looks like it will do the job. Thanks!

-Sandra
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,263
Messages
2,571,312
Members
47,988
Latest member
HarryBeck

Latest Threads

Top