summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/prserv/serv.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-06 15:59:07 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-06 23:45:36 +0000
commitbdfc5207a0fdbed889c4a5997306adab82b1c2d4 (patch)
tree814509d6cae5160fae9d9a5ad7dc2952d49a0114 /bitbake/lib/prserv/serv.py
parentafd24faa00fdf622235fc1125eddd1da8afb0323 (diff)
downloadpoky-bdfc5207a0fdbed889c4a5997306adab82b1c2d4.tar.gz
bitbake: bitbake: Always use separate process for PR Service
Using the threading module interacts badly with multiprocessing used elsewhere in bitbake under certain machine loads. This was leading to bitbake hanging on Ctrl+C when the PR Server was being used. This patch converts it to always use the daemonize code which then means the threading code isn't required. [YOCTO #3742] (Bitbake rev: 2d0bbd9398ab839bd2d1e29e50b25d52efb1ce2a) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/prserv/serv.py')
-rw-r--r--bitbake/lib/prserv/serv.py29
1 files changed, 7 insertions, 22 deletions
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index d8bdf31ba9..719941b32e 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -97,16 +97,7 @@ class PRServer(SimpleXMLRPCServer):
97 return 97 return
98 98
99 def start(self): 99 def start(self):
100 if self.daemon is True: 100 self.daemonize()
101 logger.info("PRServer: try to start daemon...")
102 self.daemonize()
103 else:
104 atexit.register(self.delpid)
105 pid = str(os.getpid())
106 pf = file(self.pidfile, 'w+')
107 pf.write("%s\n" % pid)
108 pf.close()
109 self.work_forever()
110 101
111 def delpid(self): 102 def delpid(self):
112 os.remove(self.pidfile) 103 os.remove(self.pidfile)
@@ -118,6 +109,7 @@ class PRServer(SimpleXMLRPCServer):
118 try: 109 try:
119 pid = os.fork() 110 pid = os.fork()
120 if pid > 0: 111 if pid > 0:
112 os.waitpid(pid, 0)
121 #parent return instead of exit to give control 113 #parent return instead of exit to give control
122 return 114 return
123 except OSError as e: 115 except OSError as e:
@@ -131,7 +123,7 @@ class PRServer(SimpleXMLRPCServer):
131 try: 123 try:
132 pid = os.fork() 124 pid = os.fork()
133 if pid > 0: #parent 125 if pid > 0: #parent
134 sys.exit(0) 126 os._exit(0)
135 except OSError as e: 127 except OSError as e:
136 raise Exception("%s [%d]" % (e.strerror, e.errno)) 128 raise Exception("%s [%d]" % (e.strerror, e.errno))
137 129
@@ -155,7 +147,7 @@ class PRServer(SimpleXMLRPCServer):
155 pf.close() 147 pf.close()
156 148
157 self.work_forever() 149 self.work_forever()
158 sys.exit(0) 150 os._exit(0)
159 151
160class PRServSingleton(): 152class PRServSingleton():
161 def __init__(self, dbfile, logfile, interface): 153 def __init__(self, dbfile, logfile, interface):
@@ -164,21 +156,14 @@ class PRServSingleton():
164 self.interface = interface 156 self.interface = interface
165 self.host = None 157 self.host = None
166 self.port = None 158 self.port = None
167 self.event = threading.Event()
168 159
169 def _work(self): 160 def start(self):
170 self.prserv = PRServer(self.dbfile, self.logfile, self.interface, False) 161 self.prserv = PRServer(self.dbfile, self.logfile, self.interface)
162 self.prserv.start()
171 self.host, self.port = self.prserv.getinfo() 163 self.host, self.port = self.prserv.getinfo()
172 self.event.set()
173 self.prserv.work_forever()
174 del self.prserv.db 164 del self.prserv.db
175 165
176 def start(self):
177 self.working_thread = threading.Thread(target=self._work)
178 self.working_thread.start()
179
180 def getinfo(self): 166 def getinfo(self):
181 self.event.wait()
182 return (self.host, self.port) 167 return (self.host, self.port)
183 168
184class PRServerConnection(): 169class PRServerConnection():