Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
szcloud100 opened this issue Apr 14, 2020 · 0 comments
Open

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

szcloud100 opened this issue Apr 14, 2020 · 0 comments

Comments

@szcloud100
Copy link

szcloud100 commented Apr 14, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant