Open szcloud100 opened 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)
why can't run in python 3.8.2? thx
server.py: `import asyncio import aiozmq.rpc
class Handler(aiozmq.rpc.AttrHandler):
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")
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