compas: RPC proxy not working with implicit start from Rhino/Grasshopper
Describe the bug
Using compas_rpc.Proxy
as a contextmanager raises an exception. This only happens if a RPC server is not already running. (Same/similar to #265)
To Reproduce Steps to reproduce the behavior:
Context: Grasshopper GHPython node or Rhino python editor.
Sample script
from compas.rpc import Proxy
from compas.geometry import Point
pt1 = Point(1, 2, 3)
with Proxy("compas.geometry", max_conn_attempts=5) as proxy:
pt2 = proxy.Point(1, 2, 3)
if list(pt1) == pt2:
print("Success")
- Traceback
Message: Traceback (most recent call last):
File "C:\Users\a\scoop\apps\miniconda3\4.7.12.1\envs\compas_rr_ts-dev\lib\site-packages\compas\rpc\dispatcher.py", line 100, in _dispatch
module = importlib.import_module(modulename)
File "C:\Users\a\scoop\apps\miniconda3\4.7.12.1\envs\compas_rr_ts-dev\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\a\scoop\apps\miniconda3\4.7.12.1\envs\compas_rr_ts-dev\lib\site-packages\compas\geometry\__init__.py", line 497, in <module>
from .bbox import * # noqa: F401 F403
File "C:\Users\a\scoop\apps\miniconda3\4.7.12.1\envs\compas_rr_ts-dev\lib\site-packages\compas\geometry\bbox\__init__.py", line 10, in <module>
from .bbox_numpy import * # noqa: F401 F403
File "C:\Users\a\scoop\apps\miniconda3\4.7.12.1\envs\compas_rr_ts-dev\lib\site-packages\compas\geometry\bbox\bbox_numpy.py", line 24, in <module>
from compas.numerical import pca_numpy
File "C:\Users\a\scoop\apps\miniconda3\4.7.12.1\envs\compas_rr_ts-dev\lib\site-packages\compas\numerical\__init__.py", line 109, in <module>
from .isolines import * # noqa: F401 F403
File "C:\Users\a\scoop\apps\miniconda3\4.7.12.1\envs\compas_rr_ts-dev\lib\site-packages\compas\numerical\isolines\__init__.py", line 8, in <module>
from .isolines_numpy import * # noqa: F401 F403
File "C:\Users\a\scoop\apps\miniconda3\4.7.12.1\envs\compas_rr_ts-dev\lib\site-packages\compas\numerical\isolines\isolines_numpy.py", line 11, in <module>
import matplotlib.pyplot as plt
File "C:\Users\a\scoop\apps\miniconda3\4.7.12.1\envs\compas_rr_ts-dev\lib\site-packages\matplotlib\__init__.py", line 174, in <module>
_check_versions()
File "C:\Users\a\scoop\apps\miniconda3\4.7.12.1\envs\compas_rr_ts-dev\lib\site-packages\matplotlib\__init__.py", line 159, in _check_versions
from . import ft2font
ImportError: DLL load failed while importing ft2font: %1 is not a valid Win32 application.
Traceback:
line 345, in _proxy, "C:\Users\a\AppData\Roaming\McNeel\Rhinoceros\6.0\scripts\compas\rpc\proxy.py"
line 4, in <module>, "C:\Users\a\AppData\Local\Temp\TempScript.py"
Expected behavior Print “Success”.
Desktop (please complete the following information):
- OS: Win10
- Python version 2.7.8 (IronPython 2.7.8 (2.7.8.0) on .NET 4.0.30319.42000 (64-bit))
- Python package manager: Anaconda
- compas version: 0.19.1
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 45 (45 by maintainers)
Commits related to this issue
- Backport fix for https://github.com/compas-dev/compas/issues/701 — committed to gramaziokohler/compas_mrr by tetov 3 years ago
That environment only had a compas 0.19.1 and an editable install of a package I tested compas.plugin with.
Just tested this on another computer with miniconda and it worked. Seems like my plugin package is the culprit.
I’ll investigate further, I’ll reopen if necessary.