本文整理汇总了Python中threading.Thread.localStorage方法的典型用法代码示例。如果您正苦于以下问题:Python Thread.localStorage方法的具体用法?Python Thread.localStorage怎么用?Python Thread.localStorage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类threading.Thread
的用法示例。
在下文中一共展示了Thread.localStorage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _handleRequest_Threaded
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import localStorage [as 别名]
def _handleRequest_Threaded(self,timeout,others,callback):
# self.connections is used to keep track of connection Threads
socklist = [self.sock]+others
if timeout==None:
ins,outs,exs = select.select(socklist,[],[])
else:
ins,outs,exs = select.select(socklist,[],[],timeout)
if self.sock in ins:
# it was the server socket, new incoming connection
if self._ssl_server:
from M2Crypto import SSL
try:
csock, addr = self.sock.accept()
sslsock = SSL.Connection(self.ctx,csock)
sslsock.setup_addr(addr)
sslsock.setup_ssl()
sslsock.set_accept_state()
sslsock.accept_ssl()
except SSL.SSLError,error:
Log.warn('TCPServer','SSL error: '+str(error))
print "SSL Error:",error
csock.close()
return
csock=sslsock
else:
csock, addr = self.sock.accept()
conn=TCPConnection(csock,addr)
thread=Thread(target=self.connectionHandler, args=(conn,))
thread.setDaemon(1) # thread must exit at program termination.
thread.localStorage=LocalStorage()
self.initTLS(thread.localStorage)
self.connections.append(thread)
thread.start()
示例2: _handleRequest_Threaded
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import localStorage [as 别名]
def _handleRequest_Threaded(self,timeout,others,callback):
# self.connections is used to keep track of connection Threads
socklist = [self.sock]+others
ins,outs,exs = safe_select(socklist,[],[],timeout)
if self.sock in ins:
# it was the server socket, new incoming connection
if self._ssl_server:
try:
csock, addr = self.sock.accept()
#if not Pyro.config.PYROSSL_POSTCONNCHECK:
# csock.postConnectionCheck=None
except SSL.SSLError,error:
Log.warn('TCPServer','SSL error: '+str(error))
return
else:
csock, addr = self.sock.accept()
conn=TCPConnection(csock,addr)
thread=Thread(target=self.connectionHandler, args=(conn,))
thread.setDaemon(1) # thread must exit at program termination.
thread.localStorage=LocalStorage()
self.connections.append(thread)
thread.start()
示例3: except
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import localStorage [as 别名]
return
try:
# find the object in the implementation database of our daemon
o=daemon.getLocalObject(req[0])
except (KeyError, TypeError) ,x:
Log.warn('PYROAdapter','Invocation to unknown object ignored:',x)
self.returnException(conn, ProtocolError('unknown object ID'))
return
else:
# Do the invocation. We are already running in our own thread.
if req[2]&Pyro.constants.RIF_Oneway and Pyro.config.PYRO_ONEWAY_THREADED and daemon.threaded:
# received a oneway call, run this in its own thread.
thread=Thread(target=self._handleInvocation2, args=(daemon,req,pflags,conn,o,True))
thread.setDaemon(1) # thread must exit at program termination.
thread.localStorage=LocalStorage() # set local storage for the new thread
thread.start()
else:
# not oneway or not in threaded mode, just do the invocation synchronously
self._handleInvocation2(daemon,req,pflags,conn,o,False)
def _handleInvocation2(self, daemon, req, pflags, conn, obj, mustInitTLS=False):
if mustInitTLS:
daemon.initTLS(daemon.getLocalStorage())
try:
flags=req[2]
importer=None
if not Pyro.config.PYRO_MOBILE_CODE:
res = obj.Pyro_dyncall(req[1],flags,req[3]) # (method,flags,args)
else:
try:
示例4: except
# 需要导入模块: from threading import Thread [as 别名]
# 或者: from threading.Thread import localStorage [as 别名]
return
try:
# find the object in the implementation database of our daemon
o=daemon.getLocalObject(req[0])
except (KeyError, TypeError) ,x:
Log.warn('PYROAdapter','Invocation to unknown object ignored:',x)
self.returnException(conn, ProtocolError('unknown object ID'))
return
else:
# Do the invocation. We are already running in our own thread.
if req[2]&Pyro.constants.RIF_Oneway and Pyro.config.PYRO_ONEWAY_THREADED and daemon.threaded:
# received a oneway call, run this in its own thread.
thread=Thread(target=self._handleInvocation2, args=(daemon,req,pflags,conn,o))
thread.setDaemon(1) # thread must exit at program termination.
thread.localStorage=daemon.getLocalStorage() # set local storage for the new thread
thread.start()
else:
# not oneway or not in threaded mode, just do the invocation synchronously
self._handleInvocation2(daemon,req,pflags,conn,o)
def _handleInvocation2(self, daemon, req, pflags, conn, obj):
try:
flags=req[2]
importer=None
if not Pyro.config.PYRO_MOBILE_CODE:
res = obj.Pyro_dyncall(req[1],flags,req[3]) # (method,flags,args)
else:
try:
# install a custom importer to intercept any extra needed modules
# when executing the remote method. (using the data passed in by