Wed, 12 May 2021 19:50:20 +0200
Background Server, Client: pass the path to the Python library of the eric (virtual) environment to the client to enable service plug-ins to load dependencies from there.
eric6/Utilities/BackgroundClient.py | file | annotate | diff | comparison | revisions | |
eric6/Utilities/BackgroundService.py | file | annotate | diff | comparison | revisions |
--- a/eric6/Utilities/BackgroundClient.py Wed May 12 19:48:57 2021 +0200 +++ b/eric6/Utilities/BackgroundClient.py Wed May 12 19:50:20 2021 +0200 @@ -217,12 +217,17 @@ self.connection.close() if __name__ == '__main__': - if len(sys.argv) != 4: - print('Host, port and max. processes parameters are missing.' - ' Aborting.') + if len(sys.argv) != 5: + print('Host, port, max. processes and Python library path parameters' + ' are missing. Aborting...') sys.exit(1) - host, port, maxProcs = sys.argv[1:] + host, port, maxProcs, pyLibraryPath = sys.argv[1:] + + # insert pyLibraryPath into the search path because external stuff might + # be installed in the eric (virtual) environment + sys.path.insert(1, pyLibraryPath) + backgroundClient = BackgroundClient(host, int(port), int(maxProcs)) # Start the main loop backgroundClient.run()
--- a/eric6/Utilities/BackgroundService.py Wed May 12 19:48:57 2021 +0200 +++ b/eric6/Utilities/BackgroundService.py Wed May 12 19:50:20 2021 +0200 @@ -23,9 +23,7 @@ from E5Gui.E5Application import e5App import Preferences import Utilities - -from eric6config import getConfig - +import Globals class BackgroundService(QTcpServer): """ @@ -94,13 +92,17 @@ return None backgroundClient = os.path.join( - getConfig('ericDir'), - "Utilities", "BackgroundClient.py") + os.path.dirname(__file__), "BackgroundClient.py") proc = QProcess() proc.setProcessChannelMode( QProcess.ProcessChannelMode.ForwardedChannels) - args = [backgroundClient, self.hostAddress, str(port), - str(Preferences.getUI("BackgroundServiceProcesses"))] + args = [ + backgroundClient, + self.hostAddress, + str(port), + str(Preferences.getUI("BackgroundServiceProcesses")), + Globals.getPythonLibraryDirectory(), + ] proc.start(interpreter, args) if not proc.waitForStarted(10000): proc = None