Commit 987ffc47 authored by Vincent Pelletier's avatar Vincent Pelletier

Define a poll method on storage's app.

For future extension.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2435 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 9097e48c
...@@ -87,6 +87,9 @@ class Application(object): ...@@ -87,6 +87,9 @@ class Application(object):
registerLiveDebugger(on_log=self.log) registerLiveDebugger(on_log=self.log)
def _poll(self):
self.em.poll(1)
def log(self): def log(self):
self.em.log() self.em.log()
self.logQueuedEvents() self.logQueuedEvents()
...@@ -249,14 +252,15 @@ class Application(object): ...@@ -249,14 +252,15 @@ class Application(object):
handler = verification.VerificationHandler(self) handler = verification.VerificationHandler(self)
self.master_conn.setHandler(handler) self.master_conn.setHandler(handler)
em = self.em _poll = self._poll
while not self.operational: while not self.operational:
em.poll(1) _poll()
def initialize(self): def initialize(self):
""" Retreive partition table and node informations from the primary """ """ Retreive partition table and node informations from the primary """
neo.logging.debug('initializing...') neo.logging.debug('initializing...')
_poll = self._poll
handler = initialization.InitializationHandler(self) handler = initialization.InitializationHandler(self)
self.master_conn.setHandler(handler) self.master_conn.setHandler(handler)
...@@ -270,7 +274,7 @@ class Application(object): ...@@ -270,7 +274,7 @@ class Application(object):
self.master_conn.ask(Packets.AskPartitionTable()) self.master_conn.ask(Packets.AskPartitionTable())
while not self.has_node_information or not self.has_partition_table \ while not self.has_node_information or not self.has_partition_table \
or not self.has_last_ids: or not self.has_last_ids:
self.em.poll(1) _poll()
self.ready = True self.ready = True
self.replicator.populate() self.replicator.populate()
self.master_conn.notify(Packets.NotifyReady()) self.master_conn.notify(Packets.NotifyReady())
...@@ -279,7 +283,7 @@ class Application(object): ...@@ -279,7 +283,7 @@ class Application(object):
"""Handle everything, including replications and transactions.""" """Handle everything, including replications and transactions."""
neo.logging.info('doing operation') neo.logging.info('doing operation')
em = self.em _poll = self._poll
handler = master.MasterOperationHandler(self) handler = master.MasterOperationHandler(self)
self.master_conn.setHandler(handler) self.master_conn.setHandler(handler)
...@@ -289,7 +293,7 @@ class Application(object): ...@@ -289,7 +293,7 @@ class Application(object):
self.tm.reset() self.tm.reset()
while True: while True:
em.poll(1) _poll()
if self.replicator.pending(): if self.replicator.pending():
# Call processDelayedTasks before act, so tasks added in the # Call processDelayedTasks before act, so tasks added in the
# act call are executed after one poll call, so that sent # act call are executed after one poll call, so that sent
...@@ -302,13 +306,14 @@ class Application(object): ...@@ -302,13 +306,14 @@ class Application(object):
def wait(self): def wait(self):
# change handler # change handler
neo.logging.info("waiting in hidden state") neo.logging.info("waiting in hidden state")
_poll = self._poll
handler = hidden.HiddenHandler(self) handler = hidden.HiddenHandler(self)
for conn in self.em.getConnectionList(): for conn in self.em.getConnectionList():
conn.setHandler(handler) conn.setHandler(handler)
node = self.nm.getByUUID(self.uuid) node = self.nm.getByUUID(self.uuid)
while True: while True:
self.em.poll(1) _poll()
if not node.isHidden(): if not node.isHidden():
break break
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment