forked from slackapi/bolt-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
29 lines (22 loc) · 804 Bytes
/
utils.py
File metadata and controls
29 lines (22 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
def remove_os_env_temporarily() -> dict:
old_env = os.environ.copy()
os.environ.clear()
for key, value in old_env.items():
if key.startswith("BOLT_PYTHON_"):
os.environ[key] = value
return old_env
def restore_os_env(old_env: dict) -> None:
os.environ.update(old_env)
def get_mock_server_mode() -> str:
"""Returns a str representing the mode.
:return: threading/multiprocessing
"""
mode = os.environ.get("BOLT_PYTHON_MOCK_SERVER_MODE")
if mode is None:
# We used to use "multiprocessing"" for macOS until Big Sur 11.1
# Since 11.1, the "multiprocessing" mode started failing a lot...
# Therefore, we switched the default mode back to "threading".
return "threading"
else:
return mode