473,325 Members | 2,608 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,325 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 1046

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
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
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.