我用以下 views.py 创建了一个 django apiimport datetimeimport osimport tracebackfrom logging.handlers import TimedRotatingFileHandlerfrom logging import Formatterfrom django.http import HttpResponseimport logging# from . import models as mimport pandas as pdimport jsonimport psycopg2 as pg# logger setupdef resp(status): //returns status codedef index(request): logger.info('request:' + str(request.GET)) obj = DAA() if request.method == "GET": // get values from url request if (condition): try: connection = pg.connect(dbname="dbname", user="user", password="password") cursor = connection.cursor() response = obj.level1(arguments) response = obj.level2(arguments) try: // check response except Exception as e: # add exception to log except Exception as e: # add exception to log if response : json_data = { "responseCode": 200, "version": "1.0.0", "results": [ // response ] } json_dump = json.dumps(json_data) return HttpResponse(json_dump, content_type='application/json') elif not response : json_dump = resp(400)使用上面的代码,我面临以下问题:在 jmeter 上为 100 多个用户测试应用程序时,我收到错误“已经有太多客户端”,似乎是 postgres 数据库的问题,如 conf 文件 [max_connections = 100] 但增加连接没有似乎对我有用,所以请提出其他建议。即使为少于 100 个用户运行该应用程序,我也收到此错误“RuntimeError:无法启动新线程”,因此请建议如何解决此问题?注意:-请忽略编程错误,因为我只分享了我的代码的虚拟结构。
添加回答
举报
0/150
提交
取消