aio-libs / aiozmq

Asyncio (pep 3156) integration with ZeroMQ
aiozmq.readthedocs.org
BSD 2-Clause "Simplified" License
422 stars 56 forks source link

why the Publish-Subscribe can't run? #161

Open szcloud100 opened 4 years ago

szcloud100 commented 4 years ago

server.py: `import asyncio import aiozmq.rpc

class Handler(aiozmq.rpc.AttrHandler):

def __init__(self):
    self.connected = False

@aiozmq.rpc.method
def remote_func(self, data: dict):
    self.connected = True
    print(data)

async def go(): handler = Handler() subscriber = await aiozmq.rpc.serve_pubsub( handler, subscribe='topic', bind='tcp://127.0.0.1:5566', log_exceptions=True) print("SERVE start")

while True:
    await asyncio.sleep(1)

subscriber.close()
await subscriber.wait_closed()

asyncio.run(go()) `

client.py: `import asyncio import aiozmq.rpc

async def go(): publisher = await aiozmq.rpc.connect_pubsub( connect='tcp://127.0.0.1:5566') print(publisher) await publisher.publish('topic').remote_func(2)

asyncio.run(go()) `

why can't run in python 3.8.2? thx