Пример #1
0
    def _finish(self):
        self.channel.reply_code=self.status

        DebugLogger.log('A', id(self.channel), '%d %d' % (
                self.status, self.stdout.length))

        t=self._tempfile
        if t is not None:
            self.stdout.write((file_close_producer(t), 0))
        self._tempfile=None

        self.channel.sendStreamTerminator(FCGI_STDOUT)
        self.channel.sendEndRecord()
        self.stdout.close()
        self.stderr.close()

        if not self.channel.closed:
            self.channel.push_with_producer(LoggingProducer(self.channel,
                                                            self.stdout.length,
                                                            'log_request'), 0)
        if self._shutdownRequested():
            self.channel.push(ShutdownProducer(), 0)
            Wakeup(lambda: asyncore.close_all())
        else:
            self.channel.push(None,0)
            Wakeup()
        self.channel=None
Пример #2
0
    def close(self):
        DebugLogger.log('A', id(self._request),
                        '%s %s' % (self._request.reply_code, self._bytes))
        if not self._channel.closed:
            self._channel.push(LoggingProducer(self._request, self._bytes), 0)
            self._channel.push(CallbackProducer(self._channel.done), 0)
            self._channel.push(
                CallbackProducer(lambda t=('E', id(self._request)): apply(
                    DebugLogger.log, t)), 0)
            if self._shutdown:
                self._channel.push(ShutdownProducer(), 0)
                Wakeup()
            else:
                if self._close: self._channel.push(None, 0)
            Wakeup()
        else:
            # channel closed too soon

            self._request.log(self._bytes)
            DebugLogger.log('E', id(self._request))

            if self._shutdown:
                Wakeup(lambda: asyncore.close_all())
            else:
                Wakeup()

        self._channel = None  #need to break cycles?
        self._request = None
Пример #3
0
    def close(self):
        if not self._channel.closed:
            data = self._data.getvalue()
            l = len(data)
            DebugLogger.log('A', id(self._channel),
                            '%s %s' % (self._channel.reply_code, l))
            self._channel.push('%010d%s%010d' % (l, data, 0), 0)
            self._channel.push(
                LoggingProducer(self._channel, l, 'log_request'), 0)
            self._channel.push(
                CallbackProducer(lambda t=('E', id(self._channel)): apply(
                    DebugLogger.log, t)), 0)

            if self._shutdown:
                try:
                    r = self._shutdown[0]
                except:
                    r = 0
                ZServer.exit_code = r
                self._channel.push(ShutdownProducer(), 0)
                Wakeup(lambda: asyncore.close_all())
            else:
                self._channel.push(None, 0)
                Wakeup()
        self._data = None
        self._channel = None
Пример #4
0
 def write(self, text, l=None):
     if self._channel.closed:
         return
     if l is None: l = len(text)
     self._bytes = self._bytes + l
     self._channel.push(text, 0)
     Wakeup()
Пример #5
0
 def finish(self, response):
     self._response = response
     Wakeup(self.apply)  # move callback to medusas thread