我在Lighttpd上运行了一个web.py应用程序并注意到ajax请求偶尔会失败(有时它们很好,有时候没有) - 所以我看了一下错误日志,发现它很难搞清楚:
2014-07-02 17:22:33: (mod_fastcgi.c.2673) FastCGI-stderr: Traceback (most recent call last):
2014-07-02 17:22:33: (mod_fastcgi.c.2673) FastCGI-stderr: File "/usr/local/lib/python2.7/dist-packages/web/application.py", line 237, in process
2014-07-02 17:22:33: (mod_fastcgi.c.2673) FastCGI-stderr: return p(lambda: process(processors))
2014-07-02 17:22:33: (mod_fastcgi.c.2673) FastCGI-stderr: File "/usr/local/lib/python2.7/dist-packages/web/session.py", line 85, in _processor
2014-07-02 17:22:33: (mod_fastcgi.c.2673) FastCGI-stderr: self._load()
2014-07-02 17:22:33: (mod_fastcgi.c.2673) FastCGI-stderr: File "/usr/local/lib/python2.7/dist-packages/web/session.py", line 106, in _load
2014-07-02 17:22:33: (mod_fastcgi.c.2673) FastCGI-stderr: d = self.store[self.session_id]
2014-07-02 17:22:33: (mod_fastcgi.c.2673) FastCGI-stderr: File "/usr/local/lib/python2.7/dist-packages/web/session.py", line 250, in __getitem__
2014-07-02 17:22:33: (mod_fastcgi.c.2673) FastCGI-stderr: return self.decode(pickled)
2014-07-02 17:22:33: (mod_fastcgi.c.2673) FastCGI-stderr: File "/usr/local/lib/python2.7/dist-packages/web/session.py", line 210, in decode
2014-07-02 17:22:33: (mod_fastcgi.c.2673) FastCGI-stderr: return pickle.loads(pickled)
2014-07-02 17:22:33: (mod_fastcgi.c.2673) FastCGI-stderr: EOFError
之前有没有人遇到过这些错误?
答案 0 :(得分:-1)
编辑此文件:/usr/local/lib/python2.7/dist-packages/web/session.py
import threading
lock = threading.Lock()
class DiskStore(Store):
.......
.......
def __getitem__(self, key):
path = self._get_path(key)
if os.path.exists(path):
lock.acquire()
f = open(path)
try:
pickled = f.read()
return self.decode(pickled)
finally:
f.close()
lock.release()
else:
raise KeyError, key
def __setitem__(self, key, value):
path = self._get_path(key)
pickled = self.encode(value)
try:
lock.acquire()
f = open(path, 'w')
try:
f.write(pickled)
finally:
f.close()
lock.release()
except IOError:
lock.release()
pass
2014-07-02 17:22:33:(mod_fastcgi.c.2673)FastCGI-stderr:Traceback(最近一次调用最后一次):
2014-07-02 17:22:33:(mod_fastcgi.c.2673)FastCGI-stderr:File" /usr/local/lib/python2.7/dist-packages/web/application。 py",第237行,正在处理中
2014-07-02 17:22:33:(mod_fastcgi.c.2673)FastCGI-stderr:return p(lambda:process(processors))
2014-07-02 17:22:33:(mod_fastcgi.c.2673)FastCGI-stderr:File" /usr/local/lib/python2.7/dist-packages/web/session。 py",第85行,在_processor中
2014-07-02 17:22:33:(mod_fastcgi.c.2673)FastCGI-stderr:self._load()
2014-07-02 17:22:33:(mod_fastcgi.c.2673)FastCGI-stderr:File" /usr/local/lib/python2.7/dist-packages/web/session。 py",106行,在_load中
2014-07-02 17:22:33:(mod_fastcgi.c.2673)FastCGI-stderr:d = self.store [self.session_id]
2014-07-02 17:22:33:(mod_fastcgi.c.2673)FastCGI-stderr:File" /usr/local/lib/python2.7/dist-packages/web/session。 py",第250行, getitem
2014-07-02 17:22:33:(mod_fastcgi.c.2673)FastCGI-stderr:return self.decode(pickled)
2014-07-02 17:22:33:(mod_fastcgi.c.2673)FastCGI-stderr:File" /usr/local/lib/python2.7/dist-packages/web/session。 py",第210行,在解码中
2014-07-02 17:22:33:(mod_fastcgi.c.2673)FastCGI-stderr:return pickle.loads(pickled)
2014-07-02 17:22:33:(mod_fastcgi.c.2673)FastCGI-stderr:EOFError