'Use a socketpair to be able to interrupt the ioloop if called
from another thread. Socketpair() is not supported on some OS (Win)
so use a pair of simple UDP sockets instead. The sockets will be
closed and garbage collected by python when the ioloop itself is.'

@staticmethod
def _get_interrupt_pair():

    try:
        (read_sock, write_sock) = socket.socketpair()
    except AttributeError:
        LOGGER.debug('Using    custom    socketpair    for    interrupt')
        read_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        read_sock.bind(('localhost', 0))
        write_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        write_sock.connect(read_sock.getsockname())
    read_sock.setblocking(0)
    write_sock.setblocking(0)
    return (read_sock, write_sock)
