Disconnect during connection attempt
Hello, I've been using aiomas for a RPC server and client. This works great in normal situations but there is a case where I want to disconnect whilst establishing a connection.
I call container.connect("tcp://google.com:20000/0", timeout=5), and the application does not timeout. This is a problem as I would like to be able to disconnect if I enter in a wrong address.
Is there a built in way to do this?
To replicate, you can use this code snippet
import asyncio
import aiomas
class Callee(aiomas.Agent):
# This agent does not need to override "__init__()".
# "expose"d methods can be called by other agents:
@aiomas.expose
def spam(self, times):
"""Return a lot of spam."""
return "spam" * times
class Caller(aiomas.Agent):
async def run(self, callee_addr):
print(self, "connecting to", callee_addr)
# Ask the container to make a connection to the other agent:
callee = await self.container.connect(callee_addr, 1)
print(self, "connected to", callee)
# "callee" is a proxy to the other agent. It allows us to call
# the exposed methods:
result = await callee.spam(3)
print(self, "got", result)
container = aiomas.Container.create(("localhost", 5555))
callee = Callee(container)
caller = Caller(container)
aiomas.run(until=caller.run("tcp://google.com:20000/1"))
container.shutdown()