473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Locking access to all data members

I have a class with a lot of attributes whose objects are accessed
from multiple threads. I would like to synchronize the access to all
the attributes, i.e. acquire a lock, return the value, release the
lock (in a finally clause).

Is there a way to do that without turning each attribute into a
property and manually wrapping each property with the locking code?

How about classes bound with SQLAlchemy? Is it possible to do that for
those too?

Example of a class I would like to wrap:

class Job(object):
def __init__(self, itemType):
self.id = self.idSequence
self.itemType = itemType
self.status = "waiting"
self.createDate = None
self.hostName = None
self.progress = 0
self.items = []

Jan 28 '07 #1
1 1108
gooli schrieb:
I have a class with a lot of attributes whose objects are accessed
from multiple threads. I would like to synchronize the access to all
the attributes, i.e. acquire a lock, return the value, release the
lock (in a finally clause).

Is there a way to do that without turning each attribute into a
property and manually wrapping each property with the locking code?

How about classes bound with SQLAlchemy? Is it possible to do that for
those too?

Example of a class I would like to wrap:

class Job(object):
def __init__(self, itemType):
self.id = self.idSequence
self.itemType = itemType
self.status = "waiting"
self.createDate = None
self.hostName = None
self.progress = 0
self.items = []
You can use a metaclass or decorators to put the locking code in place
for all methods. I'm not sure though if that interferes with SQLAlchemy.
Diez
Jan 28 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ryan | last post by:
I have a problem with record locking / blocking within an application. The app is quite straight forward. Written in Delphi 5 using BDE to access a SQL 7 database (Win2K server). Every so often...
16
by: Nid | last post by:
How do I do row-level locking on SQL Server? Thanks, Nid
1
by: Fardude | last post by:
ACCESS 97, Pessimistic Record Locking!??? Does Access 97 allow record level Pessimistic locking? In other words, when user A is editing a record (has it locked) and User B tries to edit it...
2
by: Scott Bryce | last post by:
I am creating a CGI application in Perl that uses an Access database. It will be hosted on an NT server. I have used flat file DBMs (tied hashes) on UNIX servers, but I am not familiar with how...
6
by: MS | last post by:
Access 97 here. I want a simple way to "lock" certain records on a form. Some records remain "live" until all data is available which happens over time. When all the fields are complete, I want...
2
by: Peter | last post by:
(I've tried this Q in the ms forums without response. See how it goes here.) Using A2003 but I guess this is not version-specific... If I want to implement row/record level locking on a split...
7
by: Shak | last post by:
Hi all, I'm trying to write a thread-safe async method to send a message of the form (type)(contents). My model is as follows: private void SendMessage(int type, string message) { //lets...
0
by: Cindy Huyser | last post by:
I have an Access 2000 database behind a threaded Java application that that can have have concurrent access to the same table (but not the same record). The database is set up for shared access...
9
by: zmickle | last post by:
Experts and books all say that you can share an Access back end on a shared drive with the front end running on each host computer. I have a simple database that tracks student data and it is...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.