Skip to content

Commit

Permalink
move get_platform_info() caching initialization to threaded init sinc…
Browse files Browse the repository at this point in the history
…e all the python versions we support have a fixed SIGCHLD handler

git-svn-id: https://xpra.org/svn/Xpra/trunk@23026 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jun 25, 2019
1 parent 54ae631 commit a44b3c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 0 additions & 8 deletions src/xpra/child_reaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,6 @@ def __init__(self, quit_cb=None):
log("using process polling every %s seconds", POLL_DELAY)
self.glib.timeout_add(POLL_DELAY*1000, self.poll)
else:
#with a less buggy python, we can just check the list of pids
#whenever we get a SIGCHLD
#however.. subprocess.Popen will no longer work as expected
#see: http://bugs.python.org/issue9127
#so we must ensure certain things that exec happen first:
from xpra.version_util import get_platform_info
get_platform_info()

signal.signal(signal.SIGCHLD, self.sigchld)
# Check once after the mainloop is running, just in case the exit
# conditions are satisfied before we even enter the main loop.
Expand Down
13 changes: 10 additions & 3 deletions src/xpra/server/server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ def init(self, opts):
from xpra.scripts import config
config.warn = log.warn
for c in SERVER_BASES:
start = monotonic_time()
c.init(self, opts)
log("ServerBase.init(%s)", opts)

end = monotonic_time()
log("%3ims in %s.init", 1000*(end-start), c)
self.sharing = opts.sharing
self.lock = opts.lock
self.idle_timeout = opts.idle_timeout
Expand All @@ -149,7 +150,10 @@ def init(self, opts):
def setup(self):
log("starting component init")
for c in SERVER_BASES:
start = monotonic_time()
c.setup(self)
end = monotonic_time()
log("%3ims in %s.setup", 1000*(end-start), c)
self.init_thread = Thread(target=self.threaded_init)
self.init_thread.start()

Expand All @@ -160,13 +164,16 @@ def threaded_init(self):
for c in SERVER_BASES:
if c!=ServerCore:
c.threaded_setup(self)
#populate the platform info cache:
from xpra.version_util import get_platform_info
get_platform_info()
log("threaded_init() end")

def wait_for_threaded_init(self):
assert self.init_thread
log("wait_for_threaded_init() %s.is_alive()=%s", self.init_thread, self.init_thread.is_alive())
if self.init_thread.is_alive():
log.info("waiting for video encoders initialization")
log.info("waiting for initialization thread to complete")
self.init_thread.join(INIT_THREAD_TIMEOUT)
if self.init_thread.is_alive():
log.warn("Warning: initialization thread is still active")
Expand Down

0 comments on commit a44b3c8

Please sign in to comment.