基本的Autobahn / Twisted示例在Python 3.5

时间:2018-04-18 01:44:17

标签: python-3.x twisted autobahn

我直接从Autobahn获取this example,将其保存为Python脚本,然后将其转移到运行Python 3.5.3的Debian 9发行版。

我试图将此文件转换为可执行的二进制文件。

我将文件保存为defer4.py。然后我跑了:

cython --embed -o defer4.c defer4.py;
gcc -Os -I /usr/include/python3.5m -o defer4 defer4.c -lpython3.5m -lpthread -lm -lutil -ldl

这在同一文件夹中创建了一个名为defer4的可执行文件。然后我运行./defer4并收到此错误:

2018-04-17T21:20:56-0400 connecting once using transport type "websocket" over endpoint "tcp"
2018-04-17T21:20:56-0400 Starting factory <autobahn.twisted.websocket.WampWebSocketClientFactory object at 0xb5a8c730>
2018-04-17T21:20:56-0400 While notifying 'join': Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/autobahn/wamp/protocol.py", line 508, in success
    d = self.fire('join', self, details)
  File "/usr/local/lib/python3.5/dist-packages/autobahn/util.py", line 817, in fire
    res.append(self._parent.fire(event, *args, **kwargs))
  File "/usr/local/lib/python3.5/dist-packages/autobahn/util.py", line 814, in fire
    future = txaio.as_future(handler, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/txaio/tx.py", line 417, in as_future
    return maybeDeferred(fun, *args, **kwargs)
--- <exception caught here> ---
  File "/usr/local/lib/python3.5/dist-packages/twisted/internet/defer.py", line 150, in maybeDeferred
    result = f(*args, **kw)
  File "/usr/local/lib/python3.5/dist-packages/twisted/internet/defer.py", line 1531, in unwindGenerator
    "instead got %r" % (f, gen))
builtins.TypeError: inlineCallbacks requires <cyfunction join at 0xb5a68030> to produce a generator; instead got <generator object at 0xb5a49300>

2018-04-17T21:20:56-0400 Unhandled error in Deferred:
2018-04-17T21:20:56-0400 Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/autobahn/wamp/protocol.py", line 508, in success
    d = self.fire('join', self, details)
  File "/usr/local/lib/python3.5/dist-packages/autobahn/util.py", line 817, in fire
    res.append(self._parent.fire(event, *args, **kwargs))
  File "/usr/local/lib/python3.5/dist-packages/autobahn/util.py", line 814, in fire
    future = txaio.as_future(handler, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/txaio/tx.py", line 417, in as_future
    return maybeDeferred(fun, *args, **kwargs)
--- <exception caught here> ---
  File "/usr/local/lib/python3.5/dist-packages/twisted/internet/defer.py", line 150, in maybeDeferred
    result = f(*args, **kw)
  File "/usr/local/lib/python3.5/dist-packages/twisted/internet/defer.py", line 1531, in unwindGenerator
    "instead got %r" % (f, gen))
builtins.TypeError: inlineCallbacks requires <cyfunction join at 0xb5a68030> to produce a generator; instead got <generator object at 0xb5a49300>

2018-04-17T21:20:56-0400 Unhandled error in Deferred:
2018-04-17T21:20:56-0400 Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/autobahn/wamp/protocol.py", line 508, in success
    d = self.fire('join', self, details)
  File "/usr/local/lib/python3.5/dist-packages/autobahn/util.py", line 817, in fire
    res.append(self._parent.fire(event, *args, **kwargs))
  File "/usr/local/lib/python3.5/dist-packages/autobahn/util.py", line 814, in fire
    future = txaio.as_future(handler, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/txaio/tx.py", line 417, in as_future
    return maybeDeferred(fun, *args, **kwargs)
--- <exception caught here> ---
  File "/usr/local/lib/python3.5/dist-packages/twisted/internet/defer.py", line 150, in maybeDeferred
    result = f(*args, **kw)
  File "/usr/local/lib/python3.5/dist-packages/twisted/internet/defer.py", line 1531, in unwindGenerator
    "instead got %r" % (f, gen))
builtins.TypeError: inlineCallbacks requires <cyfunction join at 0xb5a68030> to produce a generator; instead got <generator object at 0xb5a49300>

我一直在浏览一些文档,以了解是否有关于新Python可能会产生问题的内容,或者新Python是否正在改变其处理方式延期/发电机。我找不到任何东西。

你知道为什么即使是高速公路自己的例子也会引起这个问题吗?

1 个答案:

答案 0 :(得分:0)

Python中没有任何改变应该破坏它,我只是在Ubuntu 16.04和18.04系统上测试它,分别使用python 3.5.2和3.6.5并且一切正常。

所以问题在于你试图运行这个问题,这是高速公路没有正式支持的,所以不幸的是你几乎都在自己身上。