Context manager to clear and restore environment variables that are problematic for orca to function properly NODE_OPTIONS: When this variable is set, orca <v1.2 will have a segmentation fault due to an electron bug. See: https://github.com/electron/electron/issues/12695 E
()
| 867 | |
| 868 | @contextmanager |
| 869 | def orca_env(): |
| 870 | """ |
| 871 | Context manager to clear and restore environment variables that are |
| 872 | problematic for orca to function properly |
| 873 | |
| 874 | NODE_OPTIONS: When this variable is set, orca <v1.2 will have a |
| 875 | segmentation fault due to an electron bug. |
| 876 | See: https://github.com/electron/electron/issues/12695 |
| 877 | |
| 878 | ELECTRON_RUN_AS_NODE: When this environment variable is set the call |
| 879 | to orca is transformed into a call to nodejs. |
| 880 | See https://github.com/plotly/orca/issues/149#issuecomment-443506732 |
| 881 | """ |
| 882 | clear_env_vars = ["NODE_OPTIONS", "ELECTRON_RUN_AS_NODE", "LD_PRELOAD"] |
| 883 | orig_env_vars = {} |
| 884 | |
| 885 | try: |
| 886 | # Clear and save |
| 887 | orig_env_vars.update( |
| 888 | {var: os.environ.pop(var) for var in clear_env_vars if var in os.environ} |
| 889 | ) |
| 890 | yield |
| 891 | finally: |
| 892 | # Restore |
| 893 | for var, val in orig_env_vars.items(): |
| 894 | os.environ[var] = val |
| 895 | |
| 896 | |
| 897 | # Public orca server interaction functions |
no test coverage detected