summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/server
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-06-14 16:22:51 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-06-14 17:26:30 +0100
commit441c699acbb4b443c705933c1fccee0d906a1262 (patch)
tree63816b0140acf3052a1b673ecd8d2400f3a528b3 /bitbake/lib/bb/server
parent6c058341f9b0bee6af2554d897a2623a2ea9a479 (diff)
downloadpoky-441c699acbb4b443c705933c1fccee0d906a1262.tar.gz
bitbake: compat/server/utils: Jettison pre python 2.7.3 workarounds
Now we've moved to require python 2.7.3, we can jettison the compatibility workarounds/hacks for older python versions. (Bitbake rev: a51c402304f2080a76720f9b31d6dfdbed393bba) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/server')
-rw-r--r--bitbake/lib/bb/server/process.py46
-rw-r--r--bitbake/lib/bb/server/xmlrpc.py104
2 files changed, 11 insertions, 139 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index d73fe827e4..0d4a26ced0 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -142,52 +142,6 @@ class ProcessServer(Process, BaseImplServer):
142 def stop(self): 142 def stop(self):
143 self.keep_running.clear() 143 self.keep_running.clear()
144 144
145 def bootstrap_2_6_6(self):
146 """Pulled from python 2.6.6. Needed to ensure we have the fix from
147 http://bugs.python.org/issue5313 when running on python version 2.6.2
148 or lower."""
149
150 try:
151 self._children = set()
152 self._counter = itertools.count(1)
153 try:
154 sys.stdin.close()
155 sys.stdin = open(os.devnull)
156 except (OSError, ValueError):
157 pass
158 multiprocessing._current_process = self
159 util._finalizer_registry.clear()
160 util._run_after_forkers()
161 util.info('child process calling self.run()')
162 try:
163 self.run()
164 exitcode = 0
165 finally:
166 util._exit_function()
167 except SystemExit as e:
168 if not e.args:
169 exitcode = 1
170 elif type(e.args[0]) is int:
171 exitcode = e.args[0]
172 else:
173 sys.stderr.write(e.args[0] + '\n')
174 sys.stderr.flush()
175 exitcode = 1
176 except:
177 exitcode = 1
178 import traceback
179 sys.stderr.write('Process %s:\n' % self.name)
180 sys.stderr.flush()
181 traceback.print_exc()
182
183 util.info('process exiting with exitcode %d' % exitcode)
184 return exitcode
185
186 # Python versions 2.6.0 through 2.6.2 suffer from a multiprocessing bug
187 # which can result in a bitbake server hang during the parsing process
188 if (2, 6, 0) <= sys.version_info < (2, 6, 3):
189 _bootstrap = bootstrap_2_6_6
190
191class BitBakeProcessServerConnection(BitBakeBaseServerConnection): 145class BitBakeProcessServerConnection(BitBakeBaseServerConnection):
192 def __init__(self, serverImpl, ui_channel, event_queue): 146 def __init__(self, serverImpl, ui_channel, event_queue):
193 self.procserver = serverImpl 147 self.procserver = serverImpl
diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py
index 359d5adb67..5045e55ae2 100644
--- a/bitbake/lib/bb/server/xmlrpc.py
+++ b/bitbake/lib/bb/server/xmlrpc.py
@@ -51,100 +51,18 @@ import inspect, select
51 51
52from . import BitBakeBaseServer, BitBakeBaseServerConnection, BaseImplServer 52from . import BitBakeBaseServer, BitBakeBaseServerConnection, BaseImplServer
53 53
54if sys.hexversion < 0x020600F0: 54class BBTransport(xmlrpclib.Transport):
55 print("Sorry, python 2.6 or later is required for bitbake's XMLRPC mode") 55 def __init__(self):
56 sys.exit(1) 56 self.connection_token = None
57 57 xmlrpclib.Transport.__init__(self)
58##
59# The xmlrpclib.Transport class has undergone various changes in Python 2.7
60# which break BitBake's XMLRPC implementation.
61# To work around this we subclass Transport and have a copy/paste of method
62# implementations from Python 2.6.6's xmlrpclib.
63#
64# Upstream Python bug is #8194 (http://bugs.python.org/issue8194)
65# This bug is relevant for Python 2.7.0 and 2.7.1 but was fixed for
66# Python > 2.7.2
67#
68# To implement a simple form of client control, we use a special transport
69# that adds a HTTP header field ("Bitbake-token") to ensure that a server
70# can communicate with only a client at a given time (the client must use
71# the same token).
72##
73if (2, 7, 0) <= sys.version_info < (2, 7, 2):
74 class BBTransport(xmlrpclib.Transport):
75 def __init__(self):
76 self.connection_token = None
77 xmlrpclib.Transport.__init__(self)
78
79 def request(self, host, handler, request_body, verbose=0):
80 h = self.make_connection(host)
81 if verbose:
82 h.set_debuglevel(1)
83
84 self.send_request(h, handler, request_body)
85 self.send_host(h, host)
86 self.send_user_agent(h)
87 if self.connection_token:
88 h.putheader("Bitbake-token", self.connection_token)
89 self.send_content(h, request_body)
90
91 errcode, errmsg, headers = h.getreply()
92
93 if errcode != 200:
94 raise ProtocolError(
95 host + handler,
96 errcode, errmsg,
97 headers
98 )
99
100 self.verbose = verbose
101 58
102 try: 59 def set_connection_token(self, token):
103 sock = h._conn.sock 60 self.connection_token = token
104 except AttributeError: 61
105 sock = None 62 def send_content(self, h, body):
106 63 if self.connection_token:
107 return self._parse_response(h.getfile(), sock) 64 h.putheader("Bitbake-token", self.connection_token)
108 65 xmlrpclib.Transport.send_content(self, h, body)
109 def make_connection(self, host):
110 import httplib
111 host, extra_headers, x509 = self.get_host_info(host)
112 return httplib.HTTP(host)
113
114 def _parse_response(self, file, sock):
115 p, u = self.getparser()
116
117 while 1:
118 if sock:
119 response = sock.recv(1024)
120 else:
121 response = file.read(1024)
122 if not response:
123 break
124 if self.verbose:
125 print("body:", repr(response))
126 p.feed(response)
127
128 file.close()
129 p.close()
130
131 return u.close()
132
133 def set_connection_token(self, token):
134 self.connection_token = token
135else:
136 class BBTransport(xmlrpclib.Transport):
137 def __init__(self):
138 self.connection_token = None
139 xmlrpclib.Transport.__init__(self)
140
141 def set_connection_token(self, token):
142 self.connection_token = token
143
144 def send_content(self, h, body):
145 if self.connection_token:
146 h.putheader("Bitbake-token", self.connection_token)
147 xmlrpclib.Transport.send_content(self, h, body)
148 66
149def _create_server(host, port): 67def _create_server(host, port):
150 t = BBTransport() 68 t = BBTransport()