Files
galaxy/test/unit/test_sockets.py
T
John Chilton 0f0b4d226f Dynamic Galaxy session aware proxy for IPython, other such plugins.
This is very much an expermintal component and plugin developers shouldn't expect the API to be stable at this point. This allows plugin developers to ensure HTTP access to a single port is routes to various ports internally based on the Galaxy session of the user accessing the resource.

It is frustrating that I need to use a node-based component for this but after nights of trying I was unable to reproduce a proxy that works both dynamically and with web sockets in any Python based web framework. I tried twisted, uwsgi, tornado. My decision to use node was buttressed by the IPython team utilizing the same framework for the same reasons for their work on Juypter - https://github.com/jupyter/jupyterhub.

This is still very much a work in progress but it was languishing in my github repository and I am want to get it committed so community can hack on it and suggest (or supply) improvements.

TODO
- Replace file operations with sqlite database + write file lock (for multi-process Galaxies).
- Document configuration.
- Update galaxy-ipython to support something like proxy-prefix - configure along with the rest of this.
2014-10-18 18:38:04 -04:00

13 lines
280 B
Python

import socket
from galaxy.util import sockets
def test_unused_free_port_unconstrained():
port = sockets.unused_port()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# would throw exception if port was not free.
s.bind(('localhost', port))
s.close()