When the second if in the function is satisfied, it can be executed to the penultimate line, but the result cannot be returned properly. But the first if is satisfied and the result is returned normally
The following code runs fine in ipython and returns results.
from flask import Blueprint, request, jsonify
import json
import GetServerNumPre_RT as gn
data_input = '{"regionId":"region_id_test","type":"cop"}'
#Pre_RT = Blueprint('Pre_RT', __name__)
#@Pre_RT.route("/getServerNum", methods=["POST"])
def getServerNum():
print (' ')
print ('------ 分割线 ------')
data = json.loads(data_input) # 将json字符串转为dict
print ('解析输入参数成功')
try:
if type(data['regionId']) is list:
regionId = data['regionId'][0]
else:
regionId = data['regionId']
except:
BS_In_ROI = {"statusCode": "0001", "statusMsg": "输入参数有误", "msisdn": ""}
return (BS_In_ROI)
print ('regionId is ', regionId)
try:
if type(data['eventId']) is list:
eventId = data['eventId'][0]
else:
eventId = data['eventId']
except:
eventId = None
print ('eventId is ', eventId)
if type(data['type']) is list:
get_type = data['type'][0]
else:
get_type = data['type']
print ('get_type(1) is ', get_type)
if get_type == 'msisdn':
SN_In_ROI = gn.send_phone(regionId, eventId)
return (SN_In_ROI)
elif get_type == 'cop':
print ('get_type(2) is ', get_type)
cop_in_ROI = gn.count_of_people(regionId)
print (cop_in_ROI )
return (cop_in_ROI )
Env:
supervisord -v 4.2.4
python -v 3.8.8
Linux version 3.10.0-693.21.1.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) )
When the second if in the function is satisfied, it can be executed to the penultimate line, but the result cannot be returned properly. But the first if is satisfied and the result is returned normally
When the code is modified, running the supervisord command does not start properly .
Running gn.count_of_people(regionId) alone will return normal results. The omitted code is as follows
The following code runs fine in ipython and returns results.
Env: supervisord -v 4.2.4 python -v 3.8.8 Linux version 3.10.0-693.21.1.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) )