473,320 Members | 1,856 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.

Re: Python Query: Related to locking a resource in a multithreadedenvironment

On Mon, Aug 18, 2008 at 10:58 PM, tarun <ta**********@gmail.comwrote:
Hello All,

I've a configuration.ini file. This particular can be accessed by several
threads of my application. Each thread can read/write configuration
parameters from/to the configuration.ini file. I am using threading (Rlock)
to lock the resource (configuration.ini file) while accessing it from any
thread. I use the file available at
http://www.voidspace.org.uk/python/configobj.html for read/write.

I did the following in one of my files:

import threading
class Synchronization:
def __init__(self):
self.mutex = threading.RLock()

Now this I can create instances of the class Synchronization and use
acquire/release to work on the shared resource. But every thread would need
to import this class and hence each thread would create a separate instance
of the class. This means several lock variables. But I think we need a
global lock flag that is accessible across all the threads.

How do i do this?

Please let me know ASAP.

Thanks In Advance,
Tarun
--
http://mail.python.org/mailman/listinfo/python-list
Does making it a class level instead of instance level variable not work?

--
Stand Fast,
tjg. [Timothy Grant]
Aug 19 '08 #1
0 1044

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

Similar topics

0
by: Cameron Laird | last post by:
QOTW: "I'm starting with Python and I find it really great! It's ... natural!" Lupe http://groups.google.com/groups?selm=mailman.539.1068218589.702.python-list%40python.org "I used to default...
0
by: Peter Otten | last post by:
QOTW: "Software doesn't work, and hardware is unreliable. If you wait for a guarantee that nothing will go wrong, you'll end up being my age in a just a few dozen short decades, but without the...
1
by: Cameron Laird | last post by:
QOTW: "Alas, Python has extensive libraries and well documented to boot." - Edmond Dantes "Locking files is a complex business." - Sybren Stuvel File-locking *sounds* like an easy thing; it...
0
by: Andreas Huesgen | last post by:
Hello, I have a question refering python's reference counting/garbage collection in combination with thrown exceptions. I'm very new to this mailinglist, so I hope, that this question has not...
9
by: cgwalters | last post by:
Hi, I've recently been working on an application which does quite a bit of searching through large data structures and string matching, and I was thinking that it would help to put some of this...
0
by: =?UTF-8?B?TmlscyBPbGl2ZXIgS3LDtmdlcg==?= | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I don't think the global interpreter lock is what you need ... read here for reference: http://docs.python.org/api/threads.html
4
by: hapnendad | last post by:
In the question statement below Field names are in and variables are in (). All fields referenced are in what I have named the ‘PAR’ Table. Using MS Access 2003, I am working on a project...
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: 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
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.