def _attach_stream(self, event):
""" Attach stream to circuit. """
try:
self._controller.attach_stream(event.id, self._cid)
except (OperationFailed, InvalidRequest), error:
error = str(error)
# If circuit is already closed, close stream too.
if error in (('Unknown circuit "%s"' % self._cid),
"Can't attach stream to non-open origin circuit"):
self._controller.close_stream(event.id)
# Ignore the rare cases (~5*10^-7) where a stream has already been
# closed almost directly after its NEW-event has been received.
elif error == 'Unknown stream "%s"' % event.id:
sys.stderr.write('Stream %s has already been ' +
'closed.\n' % event.id)
else:
raise
评论列表
文章目录