summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/prserv
diff options
context:
space:
mode:
authorPaul Barker <pbarker@konsulko.com>2021-04-29 15:11:10 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-05-06 11:08:07 +0100
commit802024fd2a63bdbffbfaf125513561799452e4d2 (patch)
tree7c7af52d41a2fdd8a68f19456f461d333051b95f /bitbake/lib/prserv
parent581233a798434f178898f12fa35bbcccb92e7768 (diff)
downloadpoky-802024fd2a63bdbffbfaf125513561799452e4d2.tar.gz
bitbake: prserv: Use multiprocessing to auto start prserver
We can use the modern multiprocessing support in Python instead of manually using fork to start the prserver process. To do this we need to set up the signal handlers for the prserver process in the work_forever function (which is now used as the main function for this process). The old code to start the prserver process using fork is not removed in this commit as it is tightly intertwined with the daemonization code which will be refactored in a following commit. (Bitbake rev: b3da56240c0f92efab1c0b293738c35c0f1ee6ab) Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/prserv')
-rw-r--r--bitbake/lib/prserv/serv.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index 4375d3e590..5d6520da80 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -15,6 +15,7 @@ import prserv
15import prserv.db 15import prserv.db
16import errno 16import errno
17import select 17import select
18import multiprocessing
18 19
19logger = logging.getLogger("BitBake.PRserv") 20logger = logging.getLogger("BitBake.PRserv")
20 21
@@ -149,6 +150,9 @@ class PRServer(SimpleXMLRPCServer):
149 # if there is data there. 150 # if there is data there.
150 self.timeout = 0.01 151 self.timeout = 0.01
151 152
153 signal.signal(signal.SIGINT, self.sigint_handler)
154 signal.signal(signal.SIGTERM, self.sigterm_handler)
155
152 bb.utils.set_process_name("PRServ") 156 bb.utils.set_process_name("PRServ")
153 157
154 # DB connection must be created after all forks 158 # DB connection must be created after all forks
@@ -228,8 +232,6 @@ class PRServer(SimpleXMLRPCServer):
228 os._exit(0) 232 os._exit(0)
229 233
230 def cleanup_handles(self): 234 def cleanup_handles(self):
231 signal.signal(signal.SIGINT, self.sigint_handler)
232 signal.signal(signal.SIGTERM, self.sigterm_handler)
233 os.chdir("/") 235 os.chdir("/")
234 236
235 sys.stdout.flush() 237 sys.stdout.flush()
@@ -283,8 +285,10 @@ class PRServSingleton(object):
283 self.port = None 285 self.port = None
284 286
285 def start(self): 287 def start(self):
286 self.prserv = PRServer(self.dbfile, self.logfile, self.interface, daemon=False) 288 self.prserv = PRServer(self.dbfile, self.logfile, self.interface)
287 self.prserv.start() 289 self.process = multiprocessing.Process(target=self.prserv.work_forever)
290 self.process.start()
291
288 self.host, self.port = self.prserv.getinfo() 292 self.host, self.port = self.prserv.getinfo()
289 293
290 def getinfo(self): 294 def getinfo(self):