當前位置: 首頁>>代碼示例>>Python>>正文


Python asynchat.async_chat方法代碼示例

本文整理匯總了Python中asynchat.async_chat方法的典型用法代碼示例。如果您正苦於以下問題:Python asynchat.async_chat方法的具體用法?Python asynchat.async_chat怎麽用?Python asynchat.async_chat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在asynchat的用法示例。


在下文中一共展示了asynchat.async_chat方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import asynchat [as 別名]
# 或者: from asynchat import async_chat [as 別名]
def __init__(self, server, conn, addr):
        asynchat.async_chat.__init__(self, conn)
        self.__server = server
        self.__conn = conn
        self.__addr = addr
        self.__line = []
        self.__state = self.COMMAND
        self.__greeting = 0
        self.__mailfrom = None
        self.__rcpttos = []
        self.__data = ''
        self.__fqdn = socket.getfqdn()
        try:
            self.__peer = conn.getpeername()
        except socket.error, err:
            # a race condition  may occur if the other end is closing
            # before we can get the peername
            self.close()
            if err[0] != errno.ENOTCONN:
                raise
            return 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:23,代碼來源:smtpd.py

示例2: test_blockingioerror

# 需要導入模塊: import asynchat [as 別名]
# 或者: from asynchat import async_chat [as 別名]
def test_blockingioerror(self):
        # Issue #16133: handle_read() must ignore blocking I/O errors like
        # EAGAIN
        class fake_socket:
            def fileno(self):
                return 0

            def recv(self, size):
                raise socket.error(errno.EAGAIN, "EAGAIN")

        class MyChat(asynchat.async_chat):
            def handle_error(self):
                raise Exception("error")

        sock = fake_socket()
        dispatcher = MyChat()
        dispatcher.set_socket(sock)
        self.addCleanup(dispatcher.del_channel)

        # must not call handle_error()
        dispatcher.handle_read() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:23,代碼來源:test_asynchat.py

示例3: initiate_send

# 需要導入模塊: import asynchat [as 別名]
# 或者: from asynchat import async_chat [as 別名]
def initiate_send(self):
        asynchat.async_chat.initiate_send(self)
        if not self._closed:
            # if there's still data to send we want to be ready
            # for writing, else we're only intereseted in reading
            if not self.producer_fifo:
                wanted = self.ioloop.READ
            else:
                # In FTPHandler, we also want to listen for user input
                # hence the READ. DTPHandler has its own initiate_send()
                # which will either READ or WRITE.
                wanted = self.ioloop.READ | self.ioloop.WRITE
            if self._wanted_io_events != wanted:
                self.ioloop.modify(self._fileno, wanted)
                self._wanted_io_events = wanted
        else:
            debug("call: initiate_send(); called with no connection",
                  inst=self) 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:20,代碼來源:ioloop.py

示例4: __init__

# 需要導入模塊: import asynchat [as 別名]
# 或者: from asynchat import async_chat [as 別名]
def __init__(self, terminator, server_port):
            asynchat.async_chat.__init__(self)
            self.contents = []
            self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
            self.connect((HOST, server_port))
            self.set_terminator(terminator)
            self.buffer = b""

            def handle_connect(self):
                pass

            if sys.platform == 'darwin':
                # select.poll returns a select.POLLHUP at the end of the tests
                # on darwin, so just ignore it
                def handle_expt(self):
                    pass 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:18,代碼來源:test_asynchat.py

示例5: line_terminator_check

# 需要導入模塊: import asynchat [as 別名]
# 或者: from asynchat import async_chat [as 別名]
def line_terminator_check(self, term, server_chunk):
        event = threading.Event()
        s = echo_server(event)
        s.chunk_size = server_chunk
        s.start()
        event.wait()
        event.clear()
        time.sleep(0.01)   # Give server time to start accepting.
        c = echo_client(term, s.port)
        c.push(b"hello ")
        c.push(b"world" + term)
        c.push(b"I'm not dead yet!" + term)
        c.push(SERVER_QUIT)
        asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
        s.join(timeout=TIMEOUT)
        if s.is_alive():
            self.fail("join() timed out")

        self.assertEqual(c.contents, [b"hello world", b"I'm not dead yet!"])

    # the line terminator tests below check receiving variously-sized
    # chunks back from the server in order to exercise all branches of
    # async_chat.handle_read 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:25,代碼來源:test_asynchat.py

示例6: push

# 需要導入模塊: import asynchat [as 別名]
# 或者: from asynchat import async_chat [as 別名]
def push(self, msg):
        asynchat.async_chat.push(self, msg + '\r\n')

    # Implementation of base class abstract method 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:6,代碼來源:smtpd.py

示例7: __init__

# 需要導入模塊: import asynchat [as 別名]
# 或者: from asynchat import async_chat [as 別名]
def __init__(self, conn, baseclass):
        asynchat.async_chat.__init__(self, conn)
        self.baseclass = baseclass
        self.baseclass.last_received_data = '' 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:6,代碼來源:test_ftplib.py

示例8: push

# 需要導入模塊: import asynchat [as 別名]
# 或者: from asynchat import async_chat [as 別名]
def push(self, data):
        asynchat.async_chat.push(self, data + '\r\n') 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:4,代碼來源:test_ftplib.py

示例9: cmd_list

# 需要導入模塊: import asynchat [as 別名]
# 或者: from asynchat import async_chat [as 別名]
def cmd_list(self, arg):
        if arg:
            self.push('+OK %s %s' %(arg, arg))
        else:
            self.push('+OK')
            asynchat.async_chat.push(self, LIST_RESP) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:8,代碼來源:test_poplib.py

示例10: cmd_retr

# 需要導入模塊: import asynchat [as 別名]
# 或者: from asynchat import async_chat [as 別名]
def cmd_retr(self, arg):
        self.push('+OK %s bytes' %len(RETR_RESP))
        asynchat.async_chat.push(self, RETR_RESP) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:5,代碼來源:test_poplib.py

示例11: __init__

# 需要導入模塊: import asynchat [as 別名]
# 或者: from asynchat import async_chat [as 別名]
def __init__(self, conn):
            asynchat.async_chat.__init__(self, conn)
            self.socket = ssl.wrap_socket(self.socket, certfile=CERTFILE,
                                          server_side=True,
                                          do_handshake_on_connect=False)
            # Must try handshake before calling push()
            self._ssl_accepting = True
            self._do_ssl_handshake()
            self.set_terminator("\r\n")
            self.in_buffer = []
            self.push('+OK dummy pop3 server ready.') 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:13,代碼來源:test_poplib.py

示例12: __init__

# 需要導入模塊: import asynchat [as 別名]
# 或者: from asynchat import async_chat [as 別名]
def __init__(self, terminator, server_port):
            asynchat.async_chat.__init__(self)
            self.contents = []
            self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
            self.connect((HOST, server_port))
            self.set_terminator(terminator)
            self.buffer = '' 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:9,代碼來源:test_asynchat.py

示例13: test_numeric_terminator1

# 需要導入模塊: import asynchat [as 別名]
# 或者: from asynchat import async_chat [as 別名]
def test_numeric_terminator1(self):
        # check that ints & longs both work (since type is
        # explicitly checked in async_chat.handle_read)
        self.numeric_terminator_check(1)
        self.numeric_terminator_check(1L) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:test_asynchat.py


注:本文中的asynchat.async_chat方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。