This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

A shared resource is some resource identified by an id and used concurrently by several threads. To make the concurrent use safe, calls to resource methods are synchronized.

A resource is obtained by a call to get_resource. The required resource is identified by an id (an arbitrary object adequate as a dictionary key). If a resouce of this id already exists, it is returned. Otherwise, one is created calling the creator and the creator parameters provided to get_resource. The returned value is a wrapper around the resource. The wrapping ensures that calls to the resource’s methods are synchronized.

>>> from dm.sharedresource import get_resource
>>> r = get_resource(1, dict) # a new resource is created with the `dict` creator
>>> r is get_resource(1, dict)

The resource behaves quite like the created object. However, calls to its methods are synchronized (i.e. thread safe). However, special methods (those the names of which start and and in __) may not be found (Python 2.4 introduced that some methods must be defined at class creation time and are not longer looked up in the instance). As a special case, __getitem__, __setitem__, __delitem__, __len__, __nonzero__ are explicitely delegated.

>>> r[1] = 1
>>> r[1]

Parameters and keyword parameters for the creator can be provided as arguments to get_resource.

>>> r = get_resource('with args', dict, {1:1}, a='a', b='b')
>>> sorted(r.items())
[(1, 1), ('a', 'a'), ('b', 'b')]

Now look that normal classes work as creators, too.

>>> class Resource:
...   def __init__(self, v): self.v = v
...   def f(self): return self.v
>>> r = get_resource('class', Resource, 1)
>>> r.f()
Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
dm.sharedresource-1.0.tar.gz (4.1 kB) Copy SHA256 Checksum SHA256 Source May 28, 2008

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting