创建连接时pymongo挂起

2024-03-28 11:13:01 发布

您现在位置:Python中文网/ 问答频道 /正文

当我从Python shell运行以下行时,代码挂起:

from pymongo import Connection
c = Connection('localhost', 27017)

我想是在等待mongo服务器的回音。当我打断通话时,我得到了回溯:

^{pr2}$

mongod选择不回应吗?看起来我在等待从套接字接收数据。在

但是,这是可行的(这意味着mongod运行正常):

$ mongo --port 27017
MongoDB shell version: 2.0.1
connecting to: 127.0.0.1:27017/test

Tags: 代码fromimport服务器localhostmongoshellconnection