From dc8fda1e5af9465225c3917ea486cad29b21067c Mon Sep 17 00:00:00 2001 From: Oscar Caballero Date: Thu, 5 Apr 2018 16:26:11 +0200 Subject: [PATCH] Test nameserver shutdown with a ConnectionClosedError --- osbrain/tests/test_proxy.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/osbrain/tests/test_proxy.py b/osbrain/tests/test_proxy.py index 6f22797..91e5050 100644 --- a/osbrain/tests/test_proxy.py +++ b/osbrain/tests/test_proxy.py @@ -7,10 +7,14 @@ import pytest from threading import Timer +from Pyro4.errors import ConnectionClosedError + import osbrain from osbrain import run_agent +from osbrain import run_nameserver from osbrain import Agent from osbrain import AgentProcess +from osbrain import NameServer from osbrain import Proxy from osbrain.proxy import locate_ns from osbrain.helper import wait_agent_attr @@ -325,3 +329,17 @@ def shoot(self): assert not wayne._next_oneway assert wait_agent_attr(wayne, value=20 * ['bang!'], timeout=1.5) + + +def test_nameserver_proxy_shutdown_connectionclosed(): + """ + Check that nameserver proxies can handle a ConnectionClosedError at + shutdown. + """ + class CustomNS(NameServer): + def daemon_shutdown(self): + super().daemon_shutdown() + raise ConnectionClosedError + + ns = run_nameserver(base=CustomNS) + ns.shutdown()