本文整理汇总了Python中twisted.python.log.deferr函数的典型用法代码示例。如果您正苦于以下问题:Python deferr函数的具体用法?Python deferr怎么用?Python deferr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deferr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connectionReady
def connectionReady(self):
"""Initialize.
"""
# Some terms:
# PUID: process unique ID; return value of id() function. type "int".
# LUID: locally unique ID; an ID unique to an object mapped over this
# connection. type "int"
# GUID: (not used yet) globally unique ID; an ID for an object which
# may be on a redirected or meta server. Type as yet undecided.
self.sendCall("version", self.version)
self.currentRequestID = 0
self.currentLocalID = 0
# Dictionary mapping LUIDs to local objects.
# set above to allow root object to be assigned before connection is made
# self.localObjects = {}
# Dictionary mapping PUIDs to LUIDs.
self.luids = {}
# Dictionary mapping LUIDs to local (remotely cached) objects. Remotely
# cached means that they're objects which originate here, and were
# copied remotely.
self.remotelyCachedObjects = {}
# Dictionary mapping PUIDs to (cached) LUIDs
self.remotelyCachedLUIDs = {}
# Dictionary mapping (remote) LUIDs to (locally cached) objects.
self.locallyCachedObjects = {}
self.waitingForAnswers = {}
for notifier in self.connects:
try:
notifier()
except:
log.deferr()
self.connects = None
示例2: _doReadOrWrite
def _doReadOrWrite(self, source, condition, faildict={
error.ConnectionDone: failure.Failure(error.ConnectionDone()),
error.ConnectionLost: failure.Failure(error.ConnectionLost()),
}):
why = None
didRead = None
if condition & POLL_DISCONNECTED and \
not (condition & gobject.IO_IN):
why = main.CONNECTION_LOST
else:
try:
if condition & gobject.IO_IN:
why = source.doRead()
didRead = source.doRead
if not why and condition & gobject.IO_OUT:
# if doRead caused connectionLost, don't call doWrite
# if doRead is doWrite, don't call it again.
if not source.disconnected and source.doWrite != didRead:
why = source.doWrite()
didRead = source.doWrite # if failed it was in write
except:
why = sys.exc_info()[1]
log.msg('Error In %s' % source)
log.deferr()
if why:
self._disconnectSelectable(source, why, didRead == source.doRead)
示例3: connectionFailed
def connectionFailed(self):
for notifier in self.failures:
try:
notifier()
except:
log.deferr()
self.failures = None
示例4: display
def display(self, request):
tm = []
flip = 0
namespace = {}
self.prePresent(request)
self.addVariables(namespace, request)
# This variable may not be obscured...
namespace['request'] = request
namespace['self'] = self
for elem in self.tmpl:
flip = not flip
if flip:
if elem:
tm.append(elem)
else:
try:
x = eval(elem, namespace, namespace)
except:
log.deferr()
tm.append(webutil.formatFailure(failure.Failure()))
else:
if isinstance(x, types.ListType):
tm.extend(x)
elif isinstance(x, Widget):
val = x.display(request)
if not isinstance(val, types.ListType):
raise Exception("%s.display did not return a list, it returned %s!" % (x.__class__, repr(val)))
tm.extend(val)
else:
# Only two allowed types here should be deferred and
# string.
tm.append(x)
return tm
示例5: _doReadOrWrite
def _doReadOrWrite(self, selectable, fd, event, POLLIN, POLLOUT, log, faildict=None):
if not faildict: faildict = {
error.ConnectionDone: failure.Failure(error.ConnectionDone()),
error.ConnectionLost: failure.Failure(error.ConnectionLost())
}
why = None
inRead = False
if event & POLL_DISCONNECTED and not (event & POLLIN):
why = main.CONNECTION_LOST
else:
try:
if event & POLLIN:
why = selectable.doRead()
inRead = True
if not why and event & POLLOUT:
why = selectable.doWrite()
inRead = False
if not selectable.fileno() == fd:
why = error.ConnectionFdescWentAway('Filedescriptor went away')
inRead = False
except AttributeError, ae:
if "'NoneType' object has no attribute 'writeHeaders'" not in ae.message:
log.deferr()
why = sys.exc_info()[1]
else:
why = None
except:
示例6: _doReadOrWrite
def _doReadOrWrite(self, selectable, fd, event):
why = None
inRead = False
if event & POLL_DISCONNECTED and not (event & POLLIN):
if fd in self._reads:
why = main.CONNECTION_DONE
inRead = True
else:
why = main.CONNECTION_LOST
else:
try:
if event & POLLIN:
why = selectable.doRead()
inRead = True
if not why and event & POLLOUT:
why = selectable.doWrite()
inRead = False
if not selectable.fileno() == fd:
why = error.ConnectionFdescWentAway('Filedescriptor went away')
inRead = False
except:
log.deferr()
why = sys.exc_info()[1]
if why:
self._disconnectSelectable(selectable, why, inRead)
示例7: _doReadOrWrite
def _doReadOrWrite(self, source, condition, faildict=None):
faildict = faildict or {
error.ConnectionDone: failure.Failure(error.ConnectionDone()),
error.ConnectionLost: failure.Failure(error.ConnectionLost()),
}
why = None
inRead = False
if condition & POLL_DISCONNECTED and not (condition & glib.IO_IN):
if source in self._reads:
why = main.CONNECTION_DONE
inRead = True
else:
why = main.CONNECTION_LOST
else:
try:
if condition & glib.IO_IN:
why = source.doRead()
inRead = True
if not why and condition & glib.IO_OUT:
# if doRead caused connectionLost, don't call doWrite
# if doRead is doWrite, don't call it again.
if not source.disconnected:
why = source.doWrite()
except:
why = sys.exc_info()[1]
log.msg('Error In %s' % source)
log.deferr()
if why:
self._disconnectSelectable(source, why, inRead)
示例8: _doReadOrWrite
def _doReadOrWrite(self, selectable, fd, event, POLLIN, POLLOUT, log,
faildict={
error.ConnectionDone: failure.Failure(error.ConnectionDone()),
error.ConnectionLost: failure.Failure(error.ConnectionLost())
}):
why = None
inRead = False
if event & POLL_DISCONNECTED and not (event & POLLIN):
why = main.CONNECTION_LOST
else:
try:
if event & POLLIN:
why = selectable.doRead()
inRead = True
if not why and event & POLLOUT:
why = selectable.doWrite()
inRead = False
if not selectable.fileno() == fd:
why = error.ConnectionFdescWentAway('Filedescriptor went away')
inRead = False
except:
log.deferr()
why = sys.exc_info()[1]
if why:
self._disconnectSelectable(selectable, why, inRead)
示例9: _readAndWrite
def _readAndWrite(self, source, condition):
# note: gtk-1.2's gtk_input_add presents an API in terms of gdk
# constants like INPUT_READ and INPUT_WRITE. Internally, it will add
# POLL_HUP and POLL_ERR to the poll() events, but if they happen it
# will turn them back into INPUT_READ and INPUT_WRITE. gdkevents.c
# maps IN/HUP/ERR to INPUT_READ, and OUT/ERR to INPUT_WRITE. This
# means there is no immediate way to detect a disconnected socket.
# The g_io_add_watch() API is more suited to this task. I don't think
# pygtk exposes it, though.
why = None
didRead = None
try:
if condition & gtk.GDK.INPUT_READ:
why = source.doRead()
didRead = source.doRead
if not why and condition & gtk.GDK.INPUT_WRITE:
# if doRead caused connectionLost, don't call doWrite
# if doRead is doWrite, don't call it again.
if not source.disconnected and source.doWrite != didRead:
why = source.doWrite()
didRead = source.doWrite # if failed it was in write
except:
why = sys.exc_info()[1]
log.msg('Error In %s' % source)
log.deferr()
if why:
self._disconnectSelectable(source, why, didRead == source.doRead)
示例10: _runOperationInTransaction
def _runOperationInTransaction(self, trans, *args, **kwargs):
try:
return trans.execute(*args, **kwargs)
except:
log.msg('Exception in SQL operation %s %s'%(trans, args))
log.deferr()
raise
示例11: runUntilCurrent
def runUntilCurrent(self):
"""Run all pending timed calls.
"""
if self.threadCallQueue:
# Keep track of how many calls we actually make, as we're
# making them, in case another call is added to the queue
# while we're in this loop.
count = 0
total = len(self.threadCallQueue)
for (f, a, kw) in self.threadCallQueue:
try:
f(*a, **kw)
except:
log.err()
count += 1
if count == total:
break
del self.threadCallQueue[:count]
if len(self.threadCallQueue) > 0:
if self.waker:
self.waker.wakeUp()
# insert new delayed calls now
self._insertNewDelayedCalls()
now = seconds()
while self._pendingTimedCalls and (self._pendingTimedCalls[0].time <= now):
call = heappop(self._pendingTimedCalls)
if call.cancelled:
self._cancellations-=1
continue
if call.delayed_time > 0:
call.activate_delay()
heappush(self._pendingTimedCalls, call)
continue
try:
call.called = 1
call.func(*call.args, **call.kw)
except:
log.deferr()
if hasattr(call, "creator"):
e = "\n"
e += " C: previous exception occurred in " + \
"a DelayedCall created here:\n"
e += " C:"
e += "".join(call.creator).rstrip().replace("\n","\n C:")
e += "\n"
log.msg(e)
if (self._cancellations > 50 and
self._cancellations > len(self._pendingTimedCalls) >> 1):
self._cancellations = 0
self._pendingTimedCalls = [x for x in self._pendingTimedCalls
if not x.cancelled]
heapify(self._pendingTimedCalls)
示例12: errConnectionLost
def errConnectionLost(self):
self.lostErrorConnection = 1
del self.err
try:
self.proto.errConnectionLost()
except:
log.deferr()
self.maybeCallProcessEnded()
示例13: _runAction
def _runAction(self, action, fd):
try:
closed = getattr(fd, action)()
except:
closed = sys.exc_info()[1]
log.deferr()
if closed:
self._disconnectSelectable(fd, closed, action == 'doRead')
示例14: inConnectionLost
def inConnectionLost(self):
try:
self.proto.inConnectionLost()
except:
log.deferr()
del self.writer
self.lostInConnection = 1
self.maybeCallProcessEnded()
示例15: _continueSystemEvent
def _continueSystemEvent(self, eventType):
sysEvtTriggers = self._eventTriggers.get(eventType)
for callList in sysEvtTriggers[1], sysEvtTriggers[2]:
for callable, args, kw in callList:
try:
callable(*args, **kw)
except:
log.deferr()