multiprocessing, SyncManager, dict() of Locks possible?

R

rooster 808

I'm trying to work out a multiple readers, one writer scenerio with a
bunch of objects. Basically "foo" objects are shared across processes.
Each foo object has a .lock variable, which holds a Mutex. In
creation, I'd like to call the SyncManager, get the dict() object
which hold object_ids->lock mappings (so we can create a lock per
object only once)...

Creating the lock map happens like this:

if not object_locks.has_key(object_id):
new_lock = manager.Lock()
manager.object_locks.update({ object_id: new_lock})
Everything seems fine, except, on retrieval of the
SyncManager.get_object_locks().get(object_id) I get a

Unserializable message: ('#RETURN', <thread.lock object at 0x177b190>)

I had thought the multiprocessing Lock was serializable and shared.

Any other alternatives versus a global lock around all object writes?
 

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
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top