diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-05-28 14:28:30 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-05-30 09:54:34 +0100 |
commit | e118ee3ad85cc6e7977bbd6f5a5bd6fe57aef04e (patch) | |
tree | 9203ace51a6d0a794b0578029de01695c16558c8 /bitbake/lib/bb/server | |
parent | 5cb59cc6910d8f3165528c4a71e29e4de897d242 (diff) | |
download | poky-e118ee3ad85cc6e7977bbd6f5a5bd6fe57aef04e.tar.gz |
bitbake: server: Remove none server
The process server backend has been serving well as the default for a long
time now and the UI model is much better thought out that it used to be. With
the move to make bitbake a memory resident process, the none server is now
looking rather pointless and complicates the code needlessly. Lets therefore
now remove it.
(Bitbake rev: 9af03a89605e3db9bce3cea1e0f2d0b6cfaa6fe1)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/server')
-rw-r--r-- | bitbake/lib/bb/server/none.py | 203 |
1 files changed, 0 insertions, 203 deletions
diff --git a/bitbake/lib/bb/server/none.py b/bitbake/lib/bb/server/none.py deleted file mode 100644 index f5fd4d4f7b..0000000000 --- a/bitbake/lib/bb/server/none.py +++ /dev/null | |||
@@ -1,203 +0,0 @@ | |||
1 | # | ||
2 | # BitBake 'dummy' Passthrough Server | ||
3 | # | ||
4 | # Copyright (C) 2006 - 2007 Michael 'Mickey' Lauer | ||
5 | # Copyright (C) 2006 - 2008 Richard Purdie | ||
6 | # | ||
7 | # This program is free software; you can redistribute it and/or modify | ||
8 | # it under the terms of the GNU General Public License version 2 as | ||
9 | # published by the Free Software Foundation. | ||
10 | # | ||
11 | # This program is distributed in the hope that it will be useful, | ||
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | # GNU General Public License for more details. | ||
15 | # | ||
16 | # You should have received a copy of the GNU General Public License along | ||
17 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | |||
20 | """ | ||
21 | This module implements a passthrough server for BitBake. | ||
22 | |||
23 | Use register_idle_function() to add a function which the server | ||
24 | calls from within idle_commands when no requests are pending. Make sure | ||
25 | that those functions are non-blocking or else you will introduce latency | ||
26 | in the server's main loop. | ||
27 | """ | ||
28 | |||
29 | import time | ||
30 | import bb | ||
31 | import signal | ||
32 | |||
33 | DEBUG = False | ||
34 | |||
35 | import inspect, select | ||
36 | |||
37 | class BitBakeServerCommands(): | ||
38 | def __init__(self, server): | ||
39 | self.server = server | ||
40 | |||
41 | def runCommand(self, command): | ||
42 | """ | ||
43 | Run a cooker command on the server | ||
44 | """ | ||
45 | #print "Running Command %s" % command | ||
46 | return self.cooker.command.runCommand(command) | ||
47 | |||
48 | def terminateServer(self): | ||
49 | """ | ||
50 | Trigger the server to quit | ||
51 | """ | ||
52 | self.server.server_exit() | ||
53 | #print "Server (cooker) exitting" | ||
54 | return | ||
55 | |||
56 | def ping(self): | ||
57 | """ | ||
58 | Dummy method which can be used to check the server is still alive | ||
59 | """ | ||
60 | return True | ||
61 | |||
62 | eventQueue = [] | ||
63 | |||
64 | class BBUIEventQueue: | ||
65 | class event: | ||
66 | def __init__(self, parent): | ||
67 | self.parent = parent | ||
68 | @staticmethod | ||
69 | def send(event): | ||
70 | bb.server.none.eventQueue.append(event) | ||
71 | @staticmethod | ||
72 | def quit(): | ||
73 | return | ||
74 | |||
75 | def __init__(self, BBServer): | ||
76 | self.eventQueue = bb.server.none.eventQueue | ||
77 | self.BBServer = BBServer | ||
78 | self.EventHandle = bb.event.register_UIHhandler(self) | ||
79 | |||
80 | def __popEvent(self): | ||
81 | if len(self.eventQueue) == 0: | ||
82 | return None | ||
83 | return self.eventQueue.pop(0) | ||
84 | |||
85 | def getEvent(self): | ||
86 | if len(self.eventQueue) == 0: | ||
87 | self.BBServer.idle_commands(0) | ||
88 | return self.__popEvent() | ||
89 | |||
90 | def waitEvent(self, delay): | ||
91 | event = self.__popEvent() | ||
92 | if event: | ||
93 | return event | ||
94 | self.BBServer.idle_commands(delay) | ||
95 | return self.__popEvent() | ||
96 | |||
97 | def queue_event(self, event): | ||
98 | self.eventQueue.append(event) | ||
99 | |||
100 | def system_quit( self ): | ||
101 | bb.event.unregister_UIHhandler(self.EventHandle) | ||
102 | |||
103 | # Dummy signal handler to ensure we break out of sleep upon SIGCHLD | ||
104 | def chldhandler(signum, stackframe): | ||
105 | pass | ||
106 | |||
107 | class BitBakeNoneServer(): | ||
108 | # remove this when you're done with debugging | ||
109 | # allow_reuse_address = True | ||
110 | |||
111 | def __init__(self): | ||
112 | self._idlefuns = {} | ||
113 | self.commands = BitBakeServerCommands(self) | ||
114 | |||
115 | def addcooker(self, cooker): | ||
116 | self.cooker = cooker | ||
117 | self.commands.cooker = cooker | ||
118 | |||
119 | def register_idle_function(self, function, data): | ||
120 | """Register a function to be called while the server is idle""" | ||
121 | assert hasattr(function, '__call__') | ||
122 | self._idlefuns[function] = data | ||
123 | |||
124 | def idle_commands(self, delay): | ||
125 | #print "Idle queue length %s" % len(self._idlefuns) | ||
126 | #print "Idle timeout, running idle functions" | ||
127 | #if len(self._idlefuns) == 0: | ||
128 | nextsleep = delay | ||
129 | for function, data in self._idlefuns.items(): | ||
130 | try: | ||
131 | retval = function(self, data, False) | ||
132 | #print "Idle function returned %s" % (retval) | ||
133 | if retval is False: | ||
134 | del self._idlefuns[function] | ||
135 | elif retval is True: | ||
136 | nextsleep = None | ||
137 | elif nextsleep is None: | ||
138 | continue | ||
139 | elif retval < nextsleep: | ||
140 | nextsleep = retval | ||
141 | except SystemExit: | ||
142 | raise | ||
143 | except: | ||
144 | import traceback | ||
145 | traceback.print_exc() | ||
146 | self.commands.runCommand(["stateShutdown"]) | ||
147 | pass | ||
148 | if nextsleep is not None: | ||
149 | #print "Sleeping for %s (%s)" % (nextsleep, delay) | ||
150 | signal.signal(signal.SIGCHLD, chldhandler) | ||
151 | time.sleep(nextsleep) | ||
152 | signal.signal(signal.SIGCHLD, signal.SIG_DFL) | ||
153 | |||
154 | def server_exit(self): | ||
155 | # Tell idle functions we're exiting | ||
156 | for function, data in self._idlefuns.items(): | ||
157 | try: | ||
158 | retval = function(self, data, True) | ||
159 | except: | ||
160 | pass | ||
161 | |||
162 | class BitBakeServerConnection(): | ||
163 | def __init__(self, server): | ||
164 | self.server = server.server | ||
165 | self.connection = self.server.commands | ||
166 | self.events = bb.server.none.BBUIEventQueue(self.server) | ||
167 | for event in bb.event.ui_queue: | ||
168 | self.events.queue_event(event) | ||
169 | |||
170 | def terminate(self): | ||
171 | try: | ||
172 | self.events.system_quit() | ||
173 | except: | ||
174 | pass | ||
175 | try: | ||
176 | self.connection.terminateServer() | ||
177 | except: | ||
178 | pass | ||
179 | |||
180 | class BitBakeServer(object): | ||
181 | def initServer(self): | ||
182 | self.server = BitBakeNoneServer() | ||
183 | |||
184 | def addcooker(self, cooker): | ||
185 | self.cooker = cooker | ||
186 | self.server.addcooker(cooker) | ||
187 | |||
188 | def getServerIdleCB(self): | ||
189 | return self.server.register_idle_function | ||
190 | |||
191 | def saveConnectionDetails(self): | ||
192 | return | ||
193 | |||
194 | def detach(self): | ||
195 | return | ||
196 | |||
197 | def establishConnection(self): | ||
198 | self.connection = BitBakeServerConnection(self) | ||
199 | return self.connection | ||
200 | |||
201 | def launchUI(self, uifunc, *args): | ||
202 | return bb.cooker.server_main(self.cooker, uifunc, *args) | ||
203 | |||