使用Django
每当写一个小的电子表格文件,没问题。但是当超过700行时,继续得到502个坏网关。Nginx错误日志显示“从上游读取响应头时,上游过早关闭连接”。基于this,指出后端原因。但是,Django错误日志文件没有显示任何内容。在
Nginx中的当前设置:
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 300s;
proxy_read_timeout 300s;
#gzip on;
# Load config files from the /etc/nginx/conf.d directory
# The default server is in conf.d/default.conf
include /etc/nginx/sites-enabled/*;
}
Gunicorn正和主管一起被处决。配置行包括:
^{pr2}$更新 以下是与创建电子表格文件相关的代码:
'''
This columns contains header in excel report
'''
columns = [
(u"Origin", 10000),
(u"Deal", 2000),
(u"Customer", 10000),
(u"Plate", 2500),
(u"Serial", 6000),
(u"Sold", 3000),
(u"Clerk", 3000),
(u"Received", 3000),
]
vehiclesales = VehicleSale.objects.filter(status__lt=AGENT_SUBMITTED_STATUS).order_by('origin', 'sold')
if vehiclesales:
if format == EXPORT_EXCEL:
response = HttpResponse(mimetype='application/ms-excel')
response['Content-Disposition'] = 'attachment; filename=pending_cases.xls'
workbook = xlwt.Workbook(encoding='utf-8')
sheet = workbook.add_sheet("Pending cases")
row_num = 0
font_style = xlwt.XFStyle()
font_style.font.bold = True
for col_num in xrange(len(columns)):
sheet.write(row_num, col_num, columns[col_num][0], font_style)
# set column width
sheet.col(col_num).width = columns[col_num][1]
font_style = xlwt.XFStyle()
font_style.alignment.wrap = 1
#here we go with filling actual data in sheet
for item in vehiclesales:
vehiclesale = vehiclesale_to_dict(item)
row_num += 1
row = [
vehiclesale['origin'],
vehiclesale['deal'],
vehiclesale['customer'],
vehiclesale['plate'],
vehiclesale['vin'],
vehiclesale['sold'],
vehiclesale['clerk'],
vehiclesale['received']
]
for col_num in xrange(len(row)):
if col_num == 5:
font_style.num_format_str = 'MM/dd/yyyy'
else:
font_style.num_format_str = 'general'
sheet.write(row_num, col_num, row[col_num], font_style)
workbook.save(response)
return response
else:
no_report_template_data['report'] = 'Pending cases'
return render_to_response(no_report_template_name, no_report_template_data)
更新完成。
无论我在调用gunicorn时是否包含超时设置,都会产生不同的效果,同样的行为:总是在30秒标记处出现错误502
还要注意,如果行的数量很小(小于400),但列的数量大约为20,那么它也会失败。所以它似乎不会因为行而失败,而是因为处理了多少数据。在
请帮忙。在
目前没有回答
相关问题 更多 >
编程相关推荐