Re: Lockfile hanling

2015-04-01 Thread Sturla Molden
Ian Kelly wrote: > As long as there's not *also* some other external process that needs > to access the file occasionally. :-) Then there is multiprocessing.Lock :) -- https://mail.python.org/mailman/listinfo/python-list

Re: Lockfile hanling

2015-03-31 Thread Ian Kelly
On Tue, Mar 31, 2015 at 1:59 PM, Christian Gollwitzer wrote: > Am 31.03.15 um 21:17 schrieb Ian Kelly: >> flock locks are per-process; they won't help for synchronizing access >> between competing threads in the same process. >> > > Ok. But if it is really all in one process, then a classical mute

Re: Lockfile hanling

2015-03-31 Thread Christian Gollwitzer
Am 31.03.15 um 21:17 schrieb Ian Kelly: On Tue, Mar 31, 2015 at 12:58 PM, Christian Gollwitzer wrote: Am 31.03.15 um 16:50 schrieb Ervin Hegedüs: there is an app, written in Python, which stores few bytes of datas in a single file. The application uses threads. Every thread can modify the fil

Re: Lockfile hanling

2015-03-31 Thread Ian Kelly
On Tue, Mar 31, 2015 at 12:58 PM, Christian Gollwitzer wrote: > Am 31.03.15 um 16:50 schrieb Ervin Hegedüs: >> >> there is an app, written in Python, which stores few bytes of >> datas in a single file. The application uses threads. Every >> thread can modify the file, but only one at a time. I'm

Re: Lockfile hanling

2015-03-31 Thread Christian Gollwitzer
Am 31.03.15 um 16:50 schrieb Ervin Hegedüs: there is an app, written in Python, which stores few bytes of datas in a single file. The application uses threads. Every thread can modify the file, but only one at a time. I'm using a lock file to prevent the multiple access. Here is the lock method:

Re: Lockfile hanling

2015-03-31 Thread Ervin Hegedüs
Hi Matthew, On Tue, Mar 31, 2015 at 11:50:06AM -0400, Matthew Ruffalo wrote: > On 2015-03-31 10:50, Ervin Hegedüs wrote: > > there is an app, written in Python, which stores few bytes of > > datas in a single file. The application uses threads. Every > > thread can modify the file, but only one at

Re: Lockfile hanling

2015-03-31 Thread Matthew Ruffalo
On 2015-03-31 10:50, Ervin Hegedüs wrote: > there is an app, written in Python, which stores few bytes of > datas in a single file. The application uses threads. Every > thread can modify the file, but only one at a time. I'm using a > lock file to prevent the multiple access. > > ... > > How can I

Re: Lockfile hanling

2015-03-31 Thread Ervin Hegedüs
Hi Skip, On Tue, Mar 31, 2015 at 10:19:27AM -0500, Skip Montanaro wrote: > > sorry - at the end of the function there is a close() method to a > > file, after the thread passes the modifications: > > > > try: > > os.remove(self.lockfile) > > except: > > syslog.syslog(syslog

Re: Lockfile hanling

2015-03-31 Thread Skip Montanaro
> sorry - at the end of the function there is a close() method to a > file, after the thread passes the modifications: > > try: > os.remove(self.lockfile) > except: > syslog.syslog(syslog.LOG_DEBUG, "Sync error: " + > str(sys.exc_info()[1])) Hmmm... Still not seeing os.clo

Re: Lockfile hanling

2015-03-31 Thread Ervin Hegedüs
Hi Skip, thanks for the reply, On Tue, Mar 31, 2015 at 09:55:57AM -0500, Skip Montanaro wrote: > On Tue, Mar 31, 2015 at 9:50 AM, Ervin Hegedüs wrote: > > After few weeks the process > > reaches the number if max fd's. > > > > How can I prevent or avoid this issue? What's the correct way to > >

Re: Lockfile hanling

2015-03-31 Thread Skip Montanaro
On Tue, Mar 31, 2015 at 9:50 AM, Ervin Hegedüs wrote: > After few weeks the process > reaches the number if max fd's. > > How can I prevent or avoid this issue? What's the correct way to > handle the lockfile in Python? Ervin, You need to close the files you open. I don't see that happening in y

Lockfile hanling

2015-03-31 Thread Ervin Hegedüs
Hello, there is an app, written in Python, which stores few bytes of datas in a single file. The application uses threads. Every thread can modify the file, but only one at a time. I'm using a lock file to prevent the multiple access. Here is the lock method: while True: try: f