python一行没写完用什么隔离_在CherryPy中请求隔离是如何工作的。我不明白基本的想法...
簡言之,我不明白CherryPy在同一時間向同一資源發出兩個請求,變量是混合的還是發生了什么?在
我遇到了這個問題,我試圖用python2.7和cherrypy3.2.2創建一個非?;镜膚eb服務。在
前端使用Web服務,通過jquery/ajax向Web服務發出ajax請求。在
現在,我已經創建了一個CherryPy程序,并使用它的內置wsgi服務器。我有這樣的CherryPy配置:conf = {
'global': {
'server.socket_host': '127.0.0.1',
'server.socket_port': 8000,
},
'/': {
'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
}
}
cherrypy.quickstart(root, '/', conf)
然后我有:
^{pr2}$
實際的課程是:class getCustomers(object):
def __init__(self):
pass
exposed = True
def GET(self,callback,**kwargs):
self.callback = callback
self.cnxn= pyodbc.connect(constr)
self.cursor = self.cnxn.cursor()
cherrypy.response.headers['Content-Type']='application/json'
self.cursor.execute("""select * from customers
""", self.job_worknumber)
self.customers = self.cursor.fetchall()
self.objects_list = []
for c in self.customers
r = collections.OrderedDict()
r['customer_id'] = c.customer_id
r['customer_name'] = c.customer_name
self.objects_list.append(r)
self.cursor.close()
self.cnxn.close()
self.w = collections.OrderedDict()
self.w['data1'] = self.objects_list
#w['errors'] = 'error'
self.j = json.dumps(self.w)
#cursor2.close()
return self.callback+'('+self.j+');'
現在,當我創建一個GET請求時,我得到了我想要的,但是如果我創建的web頁面在頁面加載時向web服務發送兩個GET請求,第二個請求幾乎總是會失敗,錯誤如下:ProgrammingError: Attempt to use a closed cursor.
或其他時間:ProgrammingError: No results. Previous SQL was not a query
所以發生了什么,我的請求是否共享相同的變量,它們同時運行?我可以將CherryPy配置為一次只處理一個請求嗎?在
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的python一行没写完用什么隔离_在CherryPy中请求隔离是如何工作的。我不明白基本的想法...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: always on sql 收缩日志_S
- 下一篇: ubuntu 查看cpu运行频率_Ubu