Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
break
finally:
print_("leaving socketserver execloop")
serversock.shutdown(2)
if __name__ == "__main__":
import sys
if len(sys.argv) > 1:
hostport = sys.argv[1]
else:
hostport = ":8888"
from execnet.gateway_base import get_execmodel
execmodel = get_execmodel("thread")
serversock = bind_and_listen(hostport, execmodel)
startserver(serversock, loop=False)
elif __name__ == "__channelexec__":
chan = globals()["channel"]
execmodel = chan.gateway.execmodel
bindname = chan.receive()
sock = bind_and_listen(bindname, execmodel)
port = sock.getsockname()
chan.send(port)
startserver(sock)
execmodel can be one of "thread" or "eventlet" (XXX gevent).
It determines the execution model for any newly created gateway.
If remote_execmodel is not specified it takes on the value
of execmodel.
NOTE: Execution models can only be set before any gateway is created.
"""
if self._gateways:
raise ValueError(
"can not set execution models if " "gateways have been created already"
)
if remote_execmodel is None:
remote_execmodel = execmodel
self._execmodel = get_execmodel(execmodel)
self._remote_execmodel = get_execmodel(remote_execmodel)
execmodel can be one of "thread" or "eventlet" (XXX gevent).
It determines the execution model for any newly created gateway.
If remote_execmodel is not specified it takes on the value
of execmodel.
NOTE: Execution models can only be set before any gateway is created.
"""
if self._gateways:
raise ValueError(
"can not set execution models if " "gateways have been created already"
)
if remote_execmodel is None:
remote_execmodel = execmodel
self._execmodel = get_execmodel(execmodel)
self._remote_execmodel = get_execmodel(remote_execmodel)
"""
dispatching execution to threads or greenlets
(c) 2013, holger krekel
"""
try:
from execnet.gateway_base import get_execmodel, WorkerPool
except ImportError:
from __main__ import get_execmodel, WorkerPool
if __name__ == '__channelexec__':
size = channel.receive() # noqa
execpool = WorkerPool(get_execmodel("thread"), size)
gw = channel.gateway # noqa
channel.send("ok") # noqa
gw._trace("instantiated thread work pool size=%s" %(size,))
while 1:
gw._trace("waiting for new exec task")
task = gw._execqueue.get()
if task is None:
gw._trace("thread-dispatcher got None, exiting")
execpool.waitall()
raise gw._StopExecLoop
gw._trace("dispatching exec task to thread pool")
execpool.spawn(gw.executetask, task)
execmodel can be one of "thread" or "eventlet" (XXX gevent).
It determines the execution model for any newly created gateway.
If remote_execmodel is not specified it takes on the value
of execmodel.
NOTE: Execution models can only be set before any gateway is created.
"""
if self._gateways:
raise ValueError("can not set execution models if "
"gateways have been created already")
if remote_execmodel is None:
remote_execmodel = execmodel
self._execmodel = get_execmodel(execmodel)
self._remote_execmodel = get_execmodel(remote_execmodel)
""" Set the execution model for local and remote site.
execmodel can be one of "thread" or "eventlet" (XXX gevent).
It determines the execution model for any newly created gateway.
If remote_execmodel is not specified it takes on the value
of execmodel.
NOTE: Execution models can only be set before any gateway is created.
"""
if self._gateways:
raise ValueError("can not set execution models if "
"gateways have been created already")
if remote_execmodel is None:
remote_execmodel = execmodel
self._execmodel = get_execmodel(execmodel)
self._remote_execmodel = get_execmodel(remote_execmodel)