私は、いくつかのデータベースの要素を1つずつ表示しようとしています:
from twisted.web import server, resource
from twisted.internet import reactor
from pymongo import Connection
import time
import pprint
class ZenResource(resource.Resource):
isLeaf = True
connection = Connection('...', 27017)
db = connection.data
db.authenticate("...","...")
iter = db.index.find()
def render_GET(self, request):
item = self.iter.next()
# ... simple processing, skipped some simple strings manipulations:
htmlLines = []
for textLine in pprint.pformat(item).splitlines():
htmlLines.append('<br/>%s' % textLine)
htmlText = '\n'.join(htmlLines)
request.setHeader("Content-type", 'text/html; charset=UTF-8')
return htmlText.encode("utf8")
reactor.listenTCP(48088, server.Site(ZenResource()))
reactor.run()
1 つのシステム (Linux hh 3.0.0-16-generic-pae #28-Ubuntu SMP Fri Jan 27 19:24:01 UTC 2012 i686 i686 i386 GNU/Linux) では、すべて正常に動作します。他のシステム (Linux localhost 2.6.38-8-server #42-Ubuntu SMP Mon Apr 11 03:49:04 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux)
私は以下を得ました:
root@localhost:~# python zen.py
Bus error
私が考える2つのサーバーの唯一の違いは(x32 / x64の形式は別として)、2番目のサーバーに同様のねじれたプロセスがあることです。このプロセスは重要なことを行っており、テストコードが機能するかどうかを確認するためだけに、終了したり、他の方法で干渉したりしたくありません。