Skip to content

Commit 058e1b3

Browse files
committed
feat: modify _set_python_path location to command.py from utils.py
Signed-off-by: ImMin5 <[email protected]> (cherry picked from commit 4e07f73)
1 parent 225b670 commit 058e1b3

File tree

4 files changed

+24
-26
lines changed

4 files changed

+24
-26
lines changed

src/spaceone/core/command.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import os
22
import shutil
3+
import sys
34
import unittest
45
from typing import List
56

67
import click
8+
import pkg_resources
79

810
from spaceone.core import config, pygrpc, fastapi, utils
911
from spaceone.core import scheduler as scheduler_v1
@@ -105,9 +107,30 @@ def test(config_file=None, dir=None, failfast=False, scenario: str = None, param
105107
RichTestRunner(verbosity=verbose, failfast=failfast).run(full_suite)
106108

107109

110+
def _set_python_path(package, module_path):
111+
current_path = os.getcwd()
112+
113+
if current_path not in sys.path:
114+
sys.path.insert(0, current_path)
115+
116+
if isinstance(module_path, tuple):
117+
for path in module_path:
118+
if path not in sys.path:
119+
sys.path.insert(0, path)
120+
121+
if '.' in package:
122+
pkg_resources.declare_namespace(package)
123+
124+
try:
125+
__import__(package)
126+
except Exception:
127+
raise Exception(f'The package({package}) can not imported. '
128+
'Please check the module path.')
129+
130+
108131
def _set_server_config(package, module_path=None, port=None, config_file=None):
109132
# 1. Set a python path
110-
utils.set_python_path(package, module_path)
133+
_set_python_path(package, module_path)
111134

112135
# 2. Initialize config from command argument
113136
config.init_conf(

src/spaceone/core/config/default_conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
REST_TITLE = ''
2525
REST_DESCRIPTION = ''
2626
REST_CONTACT = {}
27-
REST_MAX_THREAD_POOL = 40
2827

2928
# REST Middlewares
3029
REST_MIDDLEWARES = []

src/spaceone/core/fastapi/server.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22

33
import uvicorn
4-
from anyio import to_thread
54
from fastapi import FastAPI
65
from fastapi.middleware.cors import CORSMiddleware
76

@@ -122,8 +121,6 @@ def _add_middlewares(app):
122121
def _init_fast_api():
123122
global_conf = config.get_global()
124123
server_info = ServerInfoManager()
125-
# set thread pool size
126-
to_thread.current_default_thread_limiter().total_tokens = global_conf.get('REST_MAX_THREAD_POOL', 40)
127124

128125
return FastAPI(
129126
title=global_conf.get('REST_TITLE', 'Document'),

src/spaceone/core/utils.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -498,26 +498,5 @@ def change_dict_with_dot_notation(dict_value: dict, key='', dots=None) -> dict:
498498
return dots
499499

500500

501-
def set_python_path(package, module_path):
502-
current_path = os.getcwd()
503-
504-
if current_path not in sys.path:
505-
sys.path.insert(0, current_path)
506-
507-
if isinstance(module_path, tuple):
508-
for path in module_path:
509-
if path not in sys.path:
510-
sys.path.insert(0, path)
511-
512-
if '.' in package:
513-
pkg_resources.declare_namespace(package)
514-
515-
try:
516-
__import__(package)
517-
except Exception:
518-
raise Exception(f'The package({package}) can not imported. '
519-
'Please check the module path.')
520-
521-
522501
if __name__ == '__main__':
523502
pass

0 commit comments

Comments
 (0)