Commit 6ba9b1d7 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Check global messages first rather than local messages. Do not create threads unnecessarily.

git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@139 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent b2f78b00
......@@ -180,7 +180,16 @@ class Application(ThreadingMixIn, object):
def _waitMessage(self,block=1):
"""Wait for a message returned by dispatcher in queues."""
# First get message we are waiting for
# First check if there are global messages and execute them
global_message = None
while 1:
try:
global_message = self.request_queue.get_nowait()
except Empty:
break
if global_message is not None:
global_message[0].handler.dispatch(global_message[0], global_message[1])
# Next get messages we are waiting for
message = None
if block:
message = self.local_var.tmp_q.get(True, None)
......@@ -192,16 +201,6 @@ class Application(ThreadingMixIn, object):
pass
if message is not None:
message[0].handler.dispatch(message[0], message[1])
# Now check if there is global messages and execute them
global_message = None
while 1:
try:
global_message = self.request_queue.get_nowait()
except Empty:
break
if global_message is not None:
global_message[0].handler.dispatch(global_message[0], global_message[1])
def connectToPrimaryMasterNode(self):
"""Connect to the primary master node."""
......
......@@ -21,6 +21,8 @@ class ThreadingMixIn:
"""Start a new thread to process the method."""
# XXX why is it necessary to start a new thread here? -yo
# XXX it is too heavy to create a new thread every time. -yo
return getattr(self, method)(**kw)
t = Thread(target = self.process_method_thread,
args = (method, kw))
t.start()
......
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