Univention Bugzilla – Attachment 5279 Details for
Bug 31752
UMC server does not reload UCR variables due to error in pyinotify.WatchManager
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
inotify.patch, cleanup
inotify.patch (text/plain), 3.65 KB, created by
Florian Best
on 2013-06-19 09:51:05 CEST
(
hide
)
Description:
inotify.patch, cleanup
Filename:
MIME Type:
Creator:
Florian Best
Created:
2013-06-19 09:51:05 CEST
Size:
3.65 KB
patch
obsolete
>Index: console/protocol/server.py >=================================================================== >--- console/protocol/server.py (Revision 41414) >+++ console/protocol/server.py (Arbeitskopie) >@@ -60,7 +60,7 @@ > > from ..resources import moduleManager, categoryManager > from ..log import CORE, CRYPT, RESOURCES >-from ..config import ucr, SERVER_MAX_CONNECTIONS >+from ..config import ucr, SERVER_MAX_CONNECTIONS, get_ucr_notifier > from ..statistics import statistics > > class MagicBucket( object ): >@@ -380,7 +380,13 @@ > self.reload() > > # register dispatch function to reload UCR Variables on change >- notifier.dispatcher_add(self._get_ucr_inotify_callback()) >+ try: >+ callback = get_ucr_notifier() >+ except OSError, exc: >+ # inotify limit is reached >+ CORE.warn('Cannot register UCR notifier: %s' % (exc)) >+ else: >+ notifier.dispatcher_add(callback) > > CORE.info( 'Initialising server process' ) > self.__port = port >@@ -468,36 +474,6 @@ > CORE.info( '__verify_cert_cb: errnum=%d depth=%d ok=%d' % (errnum, depth, ok) ) > return ok > >- def _get_ucr_inotify_callback(self): >- ''' returns a function which calls an event to reload UCR Variables if they have changed ''' >- class UCR_update_handler(pyinotify.ProcessEvent): >- def __init__(self): >- self.running = None >- def process(self): >- ''' reloads UCR Variables ''' >- ucr.load() >- CORE.info('UCR Variables have been reloaded') >- self.running = None >- return False # destroy timer >- def process_IN_MODIFY(self, event): >- if self.running: >- # remove running timer >- notifier.timer_remove(self.running) >- # add a timer which reloads UCR Variables in 10 seconds >- self.running = notifier.timer_add( 10000, self.process ) >- return True >- >- wm = pyinotify.WatchManager() >- wm.add_watch('/etc/univention/base.conf', pyinotify.IN_MODIFY) >- ucr_notifier = pyinotify.Notifier(wm, UCR_update_handler()) >- >- def cb(): >- ucr_notifier.process_events() >- if ucr_notifier.check_events(10): >- ucr_notifier.read_events() >- return True >- return cb >- > def _connection( self, socket ): > '''Signal callback: Invoked on incoming connections.''' > socket, addr = socket.accept() >Index: console/config.py >=================================================================== >--- console/config.py (Revision 41414) >+++ console/config.py (Arbeitskopie) >@@ -41,7 +41,11 @@ > some constants that are used internally. > """ > import univention.config_registry >+from .log import CORE > >+import pyinotify >+import notifier >+ > ucr = univention.config_registry.ConfigRegistry() > ucr.load() > >@@ -58,3 +62,40 @@ > > MODULE_DEBUG_LEVEL = get_int( 'umc/module/debug/level', 1 ) > MODULE_INACTIVITY_TIMER = get_int( 'umc/module/timeout', 120 ) * 1000 >+ >+BASE_CONF = '/etc/univention/base.conf' >+ >+class UCR_update_handler(pyinotify.ProcessEvent): >+ def __init__(self): >+ self.running = None >+ >+ def process(self): >+ ''' reload UCR variables ''' >+ ucr.load() >+ CORE.info('UCR variables have been reloaded') >+ self.running = None >+ return False # destroy timer >+ >+ def process_IN_MODIFY(self, event): >+ if self.running: >+ # remove running timer >+ notifier.timer_remove(self.running) >+ # add a timer which reloads UCR variables in 10 seconds >+ self.running = notifier.timer_add( 10000, self.process ) >+ return True >+ >+def get_ucr_notifier(): >+ ''' returns a function which calls an event to reload UCR variables if they have changed ''' >+ >+ wm = pyinotify.WatchManager() >+ wm.add_watch(BASE_CONF, pyinotify.IN_MODIFY) >+ ucr_notifier = pyinotify.Notifier(wm, UCR_update_handler()) >+ >+ def cb(): >+ ucr_notifier.process_events() >+ if ucr_notifier.check_events(10): >+ ucr_notifier.read_events() >+ return True >+ >+ return cb >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 31752
:
5277
| 5279