Skip to content

Commit

Permalink
Merge pull request #11419 from pllim/backport-pr11391
Browse files Browse the repository at this point in the history
Manual backport of #11391 (BUG: Fix missing "server_close" method on SAMPHubProxy)
  • Loading branch information
eteq committed Mar 25, 2021
2 parents 99fa7eb + 76ddefc commit cde0cfa
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
7 changes: 3 additions & 4 deletions astropy/samp/hub_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,12 @@ def disconnect(self):
"""
Disconnect from the current SAMP Hub.
"""
self.proxy = None
if self.proxy is not None:
self.proxy.shutdown()
self.proxy = None
self._connected = False
self.lockfile = {}

def server_close(self):
self.proxy.server_close()

@property
def _samp_hub(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion astropy/samp/tests/web_profile_test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _serve_forever(self):
self.receive_response(self._private_key,
*result['samp.params'])

self.hub.server_close()
self.hub.disconnect()

def register(self):
"""
Expand Down
12 changes: 12 additions & 0 deletions astropy/samp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ def __getattr__(self, name):
# magic method dispatcher
return _ServerProxyPoolMethod(self._proxies, name)

def shutdown(self):
"""Shut down the proxy pool by closing all active conections."""

while True:
try:
proxy = self._proxies.get_nowait()
except queue.Empty:
break
# An undocumented but apparently supported way to call methods on
# an ServerProxy that are not dispatched to the remote server
proxy('close')


class SAMPMsgReplierWrapper:
"""
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ filterwarnings =
# Ignore a warning we emit about not supporting the parallel
# reading option for now, can be removed once the issue is fixed
ignore:parallel reading does not currently work, so falling back to serial
# Ignore pytest.PytestUnhandledThreadExceptionWarning from SAMP, pytest>=6.2
ignore:Exception in thread
doctest_norecursedirs =
*/setup_package.py
doctest_subpackage_requires =
Expand Down

0 comments on commit cde0cfa

Please sign in to comment.