470,811 Members | 1,268 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,811 developers. It's quick & easy.

How to prevent from race conditions to share data between many process and thread in python

I use TurboGears to do some web service. TurboGears use cherrypy. When
web browser access this site, the cherrypy will call my python
program. So my program looks like a lib. When web browser access the
site, the http server will fock a process or gerenate a thread. I need
share some data or operate some files. How can I prevent from race
conditions. Is there any way can I lock this.
Thank you in advance!

Feb 6 '07 #1
5 2141
mars wrote:
I use TurboGears to do some web service. TurboGears use cherrypy. When
web browser access this site, the cherrypy will call my python
program. So my program looks like a lib. When web browser access the
site, the http server will fock a process or gerenate a thread. I need
share some data or operate some files. How can I prevent from race
conditions. Is there any way can I lock this.
Thank you in advance!
There are the Lock and RLock objects available in the module threading.

Diez
Feb 6 '07 #2
On 2月6日, 下午6时14分, "Diez B. Roggisch" <d...@nospam.web.dewrote:
mars wrote:
I use TurboGears to do some web service. TurboGears use cherrypy. When
web browser access this site, the cherrypy will call my python
program. So my program looks like a lib. When web browser access the
site, the http server will fock a process or gerenate a thread. I need
share some data or operate some files. How can I prevent from race
conditions. Is there any way can I lock this.
Thank you in advance!

There are the Lock and RLock objects available in the module threading.

Diez
Can this also lock mutil-process?

Feb 6 '07 #3
mars wrote:
On 2鏈6鏃, 涓嬪崍6鏃14鍒, "Diez B. Roggisch" <d...@nospam.web.dewrote:
>mars wrote:
I use TurboGears to do some web service. TurboGears use cherrypy. When
web browser access this site, the cherrypy will call my python
program. So my program looks like a lib. When web browser access the
site, the http server will fock a process or gerenate a thread. I need
share some data or operate some files. How can I prevent from race
conditions. Is there any way can I lock this.
Thank you in advance!

There are the Lock and RLock objects available in the module threading.

Diez

Can this also lock mutil-process?
No.

Diez
Feb 6 '07 #4
En Tue, 06 Feb 2007 08:49:51 -0300, Diez B. Roggisch <de***@nospam.web.de>
escribi贸:
mars wrote:
>On 2鏈6鏃, 涓嬪崍6鏃14鍒, "Diez B. Roggisch" <d...@nospam.web.dewrote:
>>mars wrote:
I use TurboGears to do some web service. TurboGears use cherrypy.
When
web browser access this site, the cherrypy will call my python
program. So my program looks like a lib. When web browser access the
site, the http server will fock a process or gerenate a thread. I
need
share some data or operate some files. How can I prevent from race
conditions. Is there any way can I lock this.
Thank you in advance!

There are the Lock and RLock objects available in the module threading.

Can this also lock mutil-process?

No.
You have to use the syncronization tools provided by your OS in that case;
maybe using a locked file (fcntl).

--
Gabriel Genellina

Feb 6 '07 #5
mars a 閏rit :
I use TurboGears to do some web service. TurboGears use cherrypy. When
web browser access this site, the cherrypy will call my python
program. So my program looks like a lib. When web browser access the
site, the http server will fock a process or gerenate a thread. I need
share some data or operate some files. How can I prevent from race
conditions. Is there any way can I lock this.
Thank you in advance!
See in the cookbook:

http://aspn.activestate.com/ASPN/sea...ype=Subsection

And test/choose one solution...
http://aspn.activestate.com/ASPN/Coo.../Recipe/252495
http://aspn.activestate.com/ASPN/Coo...n/Recipe/65203
....

A+

Laurent.
Feb 7 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by GIMME | last post: by
reply views Thread by CHURCH MOLESTED CHILDS | last post: by
reply views Thread by Richard | last post: by
18 posts views Thread by Urs Vogel | last post: by
8 posts views Thread by zdp | last post: by
1 post views Thread by Larry Bates | last post: by
5 posts views Thread by skunkwerk | last post: by
9 posts views Thread by yogamatt1970 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.