PyPy 上的龙卷风

Tornado on PyPy

我在尝试 运行 我在 pypy 上的龙卷风服务器时收到以下错误消息:

/pypy3-2.4.0-osx64/site-packages/pkg_resources/__init__.py:80: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.

有人知道这是在说什么吗?

另外为什么正常的 python 解释器允许以下功能:

   @tornado.gen.coroutine
   def get(self,id):
      doc=[]
      cursor = self.c.find({"_id":id})

      while (yield cursor.fetch_next):
         doc.append(cursor.next_object())

      return doc

但是 pypy 抱怨在生成器中使用 return。我做了一些阅读,显然正确的方法是 yield 而不是 return?

   @tornado.gen.coroutine
   def get(self,id):
      doc=[]
      cursor = self.c.find({"_id":id})

      while (yield cursor.fetch_next):
         doc.append(cursor.next_object())

      yield doc

我改用 yield 来消除 pypy 中的错误,然后恢复正常 python 然后它崩溃了。

pypy3 的当前版本基于 cpython 3.2。这已经足够老了,以至于许多软件包都放弃了对它的支持。 Tornado 不再支持 cpython 3.2,但我们支持 pypy3(不同之处在于支持 u"" unicode 文字,它存在于 pypy3 但没有重新添加到 cpython 直到 3.3).

您不能在协程中将 return 替换为 yield;这将引发 BadYieldError。相反,您必须将 return x 替换为 raise gen.Return(x)。在 python 3.3.

之前,无法在同一个函数中混合使用 returnyield