Author: dmeyer
Date: Sat Dec 30 15:36:38 2006
New Revision: 2314
Modified:
trunk/base/src/config.py
Log:
Create INotify object when needed and not global. If it is done global
the inotify fd will connect to the mainloop on import. Forking a helper
process like beacon after the fd is connected causes some strange errors
resulting in calling the wrong callback in the other process.
Modified: trunk/base/src/config.py
==============================================================================
--- trunk/base/src/config.py (original)
+++ trunk/base/src/config.py Sat Dec 30 15:36:38 2006
@@ -49,13 +49,6 @@
# align regexp
align = re.compile(u'\n( *)[^\n]', re.MULTILINE)
-try:
- _inotify = INotify()
- #raise SystemError # Debug, disable inotify.
-except SystemError:
- _inotify = None
-
-
def _format(text):
"""
Format a description with multiple lines.
@@ -532,6 +525,7 @@
self._watching = False
self._watch_mtime = 0
self._watch_timer = WeakTimer(self._check_file_changed)
+ self._inotify = None
def copy(self):
@@ -546,6 +540,7 @@
copy._autosave_timer = WeakOneShotTimer(copy.save)
return copy
+
def save(self, filename=None):
"""
Save file. If filename is not given use filename from last load.
@@ -713,20 +708,26 @@
If argument is False, disable any watches.
"""
+ if not watch and not self._inotify:
+ try:
+ self._inotify = INotify()
+ except SystemError:
+ pass
+
assert(self._filename)
if self._watch_mtime == 0:
self.load()
if not watch and self._watching:
- if _inotify:
- _inotify.ignore(self._filename)
+ if self._inotify:
+ self._inotify.ignore(self._filename)
self._watch_timer.stop()
self._watching = False
elif watch and not self._watching:
- if _inotify:
+ if self._inotify:
try:
- signal = _inotify.watch(self._filename)
+ signal = self._inotify.watch(self._filename,
INotify.MODIFY)
signal.connect_weak(self._file_changed)
except IOError:
# Adding watch falied, use timer to wait for file to
@@ -745,7 +746,7 @@
# Config file not available.
return
- if _inotify:
+ if self._inotify:
# Config file is now available, stop this timer and add INotify
# watch.
self.watch(False)
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog