def _accept_connection(self, protocol_factory, sock,
                        sslcontext=None, server=None):
     try:
         conn, addr = sock.accept()
         conn.setblocking(False)
     except (BlockingIOError, InterruptedError, ConnectionAbortedError):
         pass  # False alarm.
     except OSError as exc:
         # There's nowhere to send the error, so just log it.
         # TODO: Someone will want an error handler for this.
         if exc.errno in (errno.EMFILE, errno.ENFILE,
                          errno.ENOBUFS, errno.ENOMEM):
             # Some platforms (e.g. Linux keep reporting the FD as
             # ready, so we remove the read handler temporarily.
             # We'll try again in a while.
             logger.exception('Accept out of system resource (%s)', exc)
             self.remove_reader(sock.fileno())
             self.call_later(constants.ACCEPT_RETRY_DELAY,
                             self._start_serving,
                             protocol_factory, sock, sslcontext, server)
         else:
             raise  # The event loop will catch, log and ignore it.
     else:
         if sslcontext:
             self._make_ssl_transport(
                 conn, protocol_factory(), sslcontext, None,
                 server_side=True, extra={'peername': addr}, server=server)
         else:
             self._make_socket_transport(
                 conn, protocol_factory(), extra={'peername': addr},
                 server=server)
Ejemplo n.º 2
0
 def _accept_connection(self,
                        protocol_factory,
                        sock,
                        sslcontext=None,
                        server=None):
     try:
         conn, addr = sock.accept()
         conn.setblocking(False)
     except (BlockingIOError, InterruptedError):
         pass  # False alarm.
     except:
         # Bad error.  Stop serving.
         self.remove_reader(sock.fileno())
         sock.close()
         # There's nowhere to send the error, so just log it.
         # TODO: Someone will want an error handler for this.
         logger.exception('Accept failed')
     else:
         if sslcontext:
             self._make_ssl_transport(conn,
                                      protocol_factory(),
                                      sslcontext,
                                      None,
                                      server_side=True,
                                      extra={'addr': addr},
                                      server=server)
         else:
             self._make_socket_transport(conn,
                                         protocol_factory(),
                                         extra={'addr': addr},
                                         server=server)
Ejemplo n.º 3
0
def getPiece(data_list,temple,counter,sql):
    if temple<=100:
        sql += str(data_list.pop(0)) + ","
        counter+=1
        temple+=1
        
    if temple == 100:
        cursor.execute(sql[:len(sql)-1]+";")
        dbbean.conn.commit();
        temple = 0
        sql = 'insert into results(red1,red2,red3,red4,red5,red6,blue) values '
        print("已经保存  %s 条数据。" % counter)
    elif counter == init_length:
        temple = 0
        #print(sql[:len(sql)-1]+";")
        cursor.execute(sql[:len(sql)-1]+";")
        dbbean.conn.commit();
        return
   
    if len(data_list)!=0:
        try:
            getPiece(data_list,temple,counter,sql)
        except RuntimeError:
            logger.exception(sys.exc_info()[0])
            raise
 def _maybe_resume_protocol(self):
     if (self._protocol_paused and
         self.get_write_buffer_size() <= self._low_water):
         self._protocol_paused = False
         try:
             self._protocol.resume_writing()
         except Exception:
             logger.exception('resume_writing() failed')
Ejemplo n.º 5
0
 def _maybe_resume_protocol(self):
     if (self._protocol_paused
             and self.get_write_buffer_size() <= self._low_water):
         self._protocol_paused = False
         try:
             self._protocol.resume_writing()
         except Exception:
             logger.exception('resume_writing() failed')
 def _maybe_pause_protocol(self):
     size = self.get_write_buffer_size()
     if size <= self._high_water:
         return
     if not self._protocol_paused:
         self._protocol_paused = True
         try:
             self._protocol.pause_writing()
         except Exception:
             logger.exception('pause_writing() failed')
Ejemplo n.º 7
0
 def _maybe_pause_protocol(self):
     size = self.get_write_buffer_size()
     if size <= self._high_water:
         return
     if not self._protocol_paused:
         self._protocol_paused = True
         try:
             self._protocol.pause_writing()
         except Exception:
             logger.exception('pause_writing() failed')
Ejemplo n.º 8
0
 def _accept_connection(self, protocol_factory, sock, sslcontext=None, server=None):
     try:
         conn, addr = sock.accept()
         conn.setblocking(False)
     except (BlockingIOError, InterruptedError):
         pass  # False alarm.
     except:
         # Bad error.  Stop serving.
         self.remove_reader(sock.fileno())
         sock.close()
         # There's nowhere to send the error, so just log it.
         # TODO: Someone will want an error handler for this.
         logger.exception('Accept failed')
     else:
         if sslcontext:
             self._make_ssl_transport(conn, protocol_factory(), sslcontext, None, server_side=True, extra={'peername': addr}, server=server)
         else:
             self._make_socket_transport(conn, protocol_factory(), extra={'peername': addr}, server=server)
Ejemplo n.º 9
0
 def _accept_connection(self,
                        protocol_factory,
                        sock,
                        sslcontext=None,
                        server=None):
     try:
         conn, addr = sock.accept()
         conn.setblocking(False)
     except (BlockingIOError, InterruptedError, ConnectionAbortedError):
         pass  # False alarm.
     except OSError as exc:
         # There's nowhere to send the error, so just log it.
         # TODO: Someone will want an error handler for this.
         if exc.errno in (errno.EMFILE, errno.ENFILE, errno.ENOBUFS,
                          errno.ENOMEM):
             # Some platforms (e.g. Linux keep reporting the FD as
             # ready, so we remove the read handler temporarily.
             # We'll try again in a while.
             logger.exception('Accept out of system resource (%s)', exc)
             self.remove_reader(sock.fileno())
             self.call_later(constants.ACCEPT_RETRY_DELAY,
                             self._start_serving, protocol_factory, sock,
                             sslcontext, server)
         else:
             raise  # The event loop will catch, log and ignore it.
     else:
         if sslcontext:
             self._make_ssl_transport(conn,
                                      protocol_factory(),
                                      sslcontext,
                                      None,
                                      server_side=True,
                                      extra={'peername': addr},
                                      server=server)
         else:
             self._make_socket_transport(conn,
                                         protocol_factory(),
                                         extra={'peername': addr},
                                         server=server)
Ejemplo n.º 10
0
 def _sig_chld(self):
     try:
         while True:
             try:
                 pid, status = os.waitpid(0, os.WNOHANG)
             except ChildProcessError:
                 break
             if pid == 0:
                 continue
             elif os.WIFSIGNALED(status):
                 returncode = -os.WTERMSIG(status)
             elif os.WIFEXITED(status):
                 returncode = os.WEXITSTATUS(status)
             else:
                 # covered by
                 # SelectorEventLoopTests.test__sig_chld_unknown_status
                 # from tests/unix_events_test.py
                 # bug in coverage.py version 3.6 ???
                 continue  # pragma: no cover
             transp = self._subprocesses.get(pid)
             if transp is not None:
                 transp._process_exited(returncode)
     except Exception:
         logger.exception('Unknown exception in SIGCHLD handler')
Ejemplo n.º 11
0
 def _sig_chld(self):
     try:
         while True:
             try:
                 pid, status = os.waitpid(0, os.WNOHANG)
             except ChildProcessError:
                 break
             if pid == 0:
                 continue
             elif os.WIFSIGNALED(status):
                 returncode = -os.WTERMSIG(status)
             elif os.WIFEXITED(status):
                 returncode = os.WEXITSTATUS(status)
             else:
                 # covered by
                 # SelectorEventLoopTests.test__sig_chld_unknown_status
                 # from tests/unix_events_test.py
                 # bug in coverage.py version 3.6 ???
                 continue  # pragma: no cover
             transp = self._subprocesses.get(pid)
             if transp is not None:
                 transp._process_exited(returncode)
     except Exception:
         logger.exception('Unknown exception in SIGCHLD handler')
 def _fatal_error(self, exc):
     # Should be called from exception handler only.
     if not isinstance(exc, (BrokenPipeError, ConnectionResetError)):
         logger.exception('Fatal error for %s', self)
     self._force_close(exc)
Ejemplo n.º 13
0
 def _fatal_error(self, exc):
     # should be called by exception handler only
     if not isinstance(exc, (BrokenPipeError, ConnectionResetError)):
         logger.exception('Fatal error for %s', self)
     self._close(exc)
Ejemplo n.º 14
0
 def _fatal_error(self, exc):
     # should be called by exception handler only
     if not (isinstance(exc, OSError) and exc.errno == errno.EIO):
         logger.exception('Fatal error for %s', self)
     self._close(exc)
Ejemplo n.º 15
0
 def _fatal_error(self, exc):
     # should be called by exception handler only
     if not (isinstance(exc, OSError) and exc.errno == errno.EIO):
         logger.exception('Fatal error for %s', self)
     self._close(exc)