def checkSocketLib(): # Workaround: Detect closed NIO_GROUP and ee-create it try: if _socket.NIO_GROUP.isShutdown(): _socket.NIO_GROUP = _socket.NioEventLoopGroup(2, _socket.DaemonThreadFactory("PyScan-Netty-Client-%s")) sys.registerCloser(_socket._shutdown_threadpool) except AttributeError: raise Exception("Jython _socket.py has changed from jython_2.7.0")
def checkSocketLib(): # Workaround: Detect closed NIO_GROUP and re-create it try: if _socket.NIO_GROUP.isShutdown(): _socket.NIO_GROUP = _socket.NioEventLoopGroup( 2, _socket.DaemonThreadFactory("PyScan-Netty-Client-%s")) sys.registerCloser(_socket._shutdown_threadpool) except AttributeError: raise Exception("Jython _socket.py has changed from jython_2.7.0")
def checkSocketLib(): # Workaround: Detect closed NIO_GROUP and ee-create it try: if _socket.NIO_GROUP.isShutdown(): # print "RE-CREATEING NIO_GROUP!!!!!!!!!" # _socket._NUM_THREADS is 10. Using only 2 threads. _socket.NIO_GROUP = _socket.NioEventLoopGroup( 2, _socket.DaemonThreadFactory("PyScan-Netty-Client-%s")) sys.registerCloser(_socket._shutdown_threadpool) except AttributeError: print "Jython _socket.py has changed from jython_2.7.0"
_PEER_CLOSED = object() NIO_GROUP = NioEventLoopGroup() def _shutdown_threadpool(): print >> sys.stderr, "Shutting down thread pool..." # FIXME this timeout probably should be configurable; for client # usage that have completed this probably only produces scary # messages at worst, but TBD; in particular this may because we # are seeing closes both in SSL and at the socket level NIO_GROUP.shutdownGracefully(0, 100, TimeUnit.MILLISECONDS) print >> sys.stderr, "Shut down thread pool." # Ensure deallocation of thread pool if PySystemState.cleanup is # called; this includes in the event of sigterm sys.registerCloser(_shutdown_threadpool) class error(IOError): pass class herror(error): pass class gaierror(error): pass class timeout(error): pass class _Select(object): def __init__(self, rlist, wlist, xlist): self.cv = Condition() self.rlist = frozenset(rlist) self.wlist = frozenset(wlist) self.xlist = frozenset(xlist)