Merge branch 'windows-subprocess-fix'
This commit is contained in:
@@ -12,11 +12,15 @@ bl_info = {
|
||||
'category': 'System',
|
||||
'support': 'TESTING',
|
||||
}
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
if 'bpy' in locals():
|
||||
try:
|
||||
import bpy
|
||||
except ImportError:
|
||||
from . import subproc
|
||||
else:
|
||||
if 'bpkg' in locals():
|
||||
from importlib import reload
|
||||
|
||||
def recursive_reload(mod):
|
||||
@@ -35,7 +39,6 @@ if 'bpy' in locals():
|
||||
bpkg = recursive_reload(bpkg)
|
||||
Package = bpkg.types.Package
|
||||
|
||||
else:
|
||||
from . import subproc
|
||||
from . import messages
|
||||
from . import bpkg
|
||||
@@ -44,10 +47,11 @@ else:
|
||||
Package,
|
||||
ConsolidatedPackage,
|
||||
)
|
||||
|
||||
import bpy
|
||||
from pathlib import Path
|
||||
from collections import OrderedDict
|
||||
import multiprocessing
|
||||
mp_context = multiprocessing.get_context('spawn')
|
||||
mp_context.set_executable(bpy.app.binary_path_python)
|
||||
|
||||
# global list of all known packages, indexed by name
|
||||
_packages = OrderedDict()
|
||||
@@ -74,8 +78,6 @@ class SubprocMixin:
|
||||
self._state = 'QUIT'
|
||||
|
||||
def invoke(self, context, event):
|
||||
import multiprocessing
|
||||
|
||||
self.pipe_blender, self.pipe_subproc = multiprocessing.Pipe()
|
||||
|
||||
# The subprocess should just be terminated when Blender quits. Without this,
|
||||
@@ -135,7 +137,6 @@ class SubprocMixin:
|
||||
self.pipe_blender.send(messages.Abort())
|
||||
|
||||
def _finish(self, context):
|
||||
import multiprocessing
|
||||
try:
|
||||
self.cancel(context)
|
||||
except AttributeError:
|
||||
@@ -213,8 +214,6 @@ class PACKAGE_OT_install(SubprocMixin, bpy.types.Operator):
|
||||
:rtype: multiprocessing.Process
|
||||
"""
|
||||
|
||||
import multiprocessing
|
||||
|
||||
self.msg_handlers = {
|
||||
messages.Progress: self._subproc_progress,
|
||||
messages.DownloadError: self._subproc_download_error,
|
||||
@@ -234,7 +233,7 @@ class PACKAGE_OT_install(SubprocMixin, bpy.types.Operator):
|
||||
self.log.debug("Using %s as install path", install_path)
|
||||
|
||||
import addon_utils
|
||||
proc = multiprocessing.Process(target=subproc.download_and_install_package,
|
||||
proc = mp_context.Process(target=subproc.download_and_install_package,
|
||||
args=(self.pipe_subproc, package, install_path))
|
||||
return proc
|
||||
|
||||
@@ -289,8 +288,6 @@ class PACKAGE_OT_uninstall(SubprocMixin, bpy.types.Operator):
|
||||
:rtype: multiprocessing.Process
|
||||
"""
|
||||
|
||||
import multiprocessing
|
||||
|
||||
self.msg_handlers = {
|
||||
messages.UninstallError: self._subproc_uninstall_error,
|
||||
messages.Success: self._subproc_success,
|
||||
@@ -302,7 +299,7 @@ class PACKAGE_OT_uninstall(SubprocMixin, bpy.types.Operator):
|
||||
global _packages
|
||||
package = _packages[self.package_name].get_latest_version()
|
||||
|
||||
proc = multiprocessing.Process(target=subproc.uninstall_package,
|
||||
proc = mp_context.Process(target=subproc.uninstall_package,
|
||||
args=(self.pipe_subproc, package, install_path))
|
||||
return proc
|
||||
|
||||
@@ -400,8 +397,6 @@ class PACKAGE_OT_refresh(SubprocMixin, bpy.types.Operator):
|
||||
:rtype: multiprocessing.Process
|
||||
"""
|
||||
|
||||
import multiprocessing
|
||||
|
||||
#TODO: make sure all possible messages are handled
|
||||
self.msg_handlers = {
|
||||
messages.Progress: self._subproc_progress,
|
||||
@@ -419,7 +414,7 @@ class PACKAGE_OT_refresh(SubprocMixin, bpy.types.Operator):
|
||||
repository_urls = [repo.url for repo in self.repositories]
|
||||
self.log.debug("Repository urls %s", repository_urls)
|
||||
|
||||
proc = multiprocessing.Process(target=subproc.refresh_repositories,
|
||||
proc = mp_context.Process(target=subproc.refresh_repositories,
|
||||
args=(self.pipe_subproc, storage_path, repository_urls))
|
||||
return proc
|
||||
|
||||
|
Reference in New Issue
Block a user