Commit aa84b719 authored by sumpfralle's avatar sumpfralle

simplified the handling of the different states of parallel/server mode


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@980 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 2b6a3934
......@@ -6292,7 +6292,23 @@ You will need remote workers.&lt;/span&gt;</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame1">
<object class="GtkLabel" id="ServerModeDisabledLabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Server mode is currently not available on your system.
You are probably using the Windows standalone executable.
Instead you could use the PyCAM installer package along with the all-in-one installer of all dependencies.
See the &lt;a href="http://sf.net/apps/mediawiki/pycam/?title=Parallel_Processing_on_different_Platforms"&gt;platform feature matrix&lt;/a&gt; for details.</property>
<property name="use_markup">True</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="ServerModeSettingsFrame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
......@@ -6530,7 +6546,7 @@ The default port is 1250.</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
</object>
......@@ -6545,16 +6561,8 @@ The default port is 1250.</property>
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Parallel processing is currently not available on your system.
Please check the following list of possible reasons and fix the problem, if possible.
1) You are using the Windows standalone executable.
Sadly this problem is not too easy to solve. Future releases of PyCAM should remove this limitation.
2) You are using Python 2.5 or below and the package "multiprocessing" is &lt;i&gt;not&lt;/i&gt; installed.
See the &lt;a href="http://sf.net/apps/mediawiki/pycam/?title=Parallel_Processing_on_different_Platforms"&gt;platform feature matrix&lt;/a&gt; for details.
</property>
<property name="use_markup">True</property>
You need to switch to Python v2.6 (or higher) or install the Python module "multiprocessing".
</property>
<property name="wrap">True</property>
</object>
<packing>
......
......@@ -942,12 +942,15 @@ class ProjectGui:
# parallel processing settings
self.enable_parallel_processes = self.gui.get_object(
"EnableParallelProcesses")
if pycam.Utils.threading.is_parallel_processing_available():
if pycam.Utils.threading.is_multiprocessing_available():
self.gui.get_object("ParallelProcessingDisabledLabel").hide()
if pycam.Utils.threading.is_server_mode_available():
self.gui.get_object("ServerModeDisabledLabel").hide()
else:
self.gui.get_object("ServerModeSettingsFrame").hide()
else:
self.gui.get_object("ParallelProcessSettingsBox").hide()
self.enable_parallel_processes.set_sensitive(False)
self.enable_parallel_processes.set_active(False)
self.gui.get_object("EnableParallelProcesses").hide()
self.enable_parallel_processes.set_active(
pycam.Utils.threading.is_multiprocessing_enabled())
self.enable_parallel_processes.connect("toggled",
......
......@@ -82,17 +82,25 @@ def run_in_parallel(*args, **kwargs):
def is_pool_available():
return not __manager is None
def is_multiprocessing_available():
try:
import multiprocessing
return True
except ImportError:
return False
def is_multiprocessing_enabled():
return bool(__multiprocessing)
def is_windows_parallel_processing_available():
# server mode is disabled for the Windows standalone executable
return not (hasattr(sys, "frozen") and sys.frozen)
def is_parallel_processing_available():
if not is_windows_parallel_processing_available():
# Windows -> no parallel processing
def is_server_mode_available():
# the following definition should be kept in sync with the wiki:
# http://sf.net/apps/mediawiki/pycam/?title=Parallel_Processing_on_different_Platforms
if pycam.Utils.get_platform() == pycam.Utils.PLATFORM_WINDOWS:
if hasattr(sys, "frozen") and sys.frozen:
return False
else:
return True
else:
try:
import multiprocessing
return True
......@@ -156,8 +164,7 @@ def init_threading(number_of_processes=None, enable_server=False, remote=None,
if __multiprocessing:
# kill the manager and clean everything up for a re-initialization
cleanup()
if (not is_windows_parallel_processing_available()) and \
(enable_server or run_server):
if (not is_server_mode_available()) and (enable_server or run_server):
# server mode is disabled for the Windows pyinstaller standalone
# due to "pickle errors". How to reproduce: run the standalone binary
# with "--enable-server --server-auth-key foo".
......@@ -181,16 +188,6 @@ def init_threading(number_of_processes=None, enable_server=False, remote=None,
remote = None
run_server = None
server_credentials = ""
if not is_windows_parallel_processing_available():
# Running multiple processes with the Windows standalone executable
# causes "WindowsError: invalid handle" error messages. The processes
# can't communicate - thus no results are returned.
# Reproduce with: "--number-of-processes 2"
log.info("Multiprocessing capabilities are not available for the " \
+ "Windows standable executable. Use the installer package " \
+ "instead (if possible).")
mp_is_available = False
else:
try:
import multiprocessing
mp_is_available = True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment