💾 Archived View for tris.fyi › pydoc › asynchat captured on 2022-01-08 at 13:39:08. Gemini links have been rewritten to link to archived content

View Raw

More Information

➡️ Next capture (2023-01-29)

-=-=-=-=-=-=-

Back to module index

Go to module by name

asynchat

A class supporting chat-style (command/response) protocols.

This class adds support for 'chat' style protocols - where one side
sends a 'command', and the other sends a response (examples would be
the common internet protocols - smtp, nntp, ftp, etc..).

The handle_read() method looks at the input stream for the current
'terminator' (usually '\r\n' for single-line responses, '\r\n.\r\n'
for multi-line output), calling self.found_terminator() on its
receipt.

for example:
Say you build an async nntp client using this class.  At the start
of the connection, you'll have self.terminator set to '\r\n', in
order to process the single-line greeting.  Just before issuing a
'LIST' command you'll set it to '\r\n.\r\n'.  The output of the LIST
command will be accumulated (using your own 'collect_incoming_data'
method) up to the terminator, and then control will be returned to
you - by calling your self.found_terminator() method.

Classes

async_chat

This is an abstract class.  You must derive from this class, and add
    the two methods collect_incoming_data() and found_terminator()
accept(self)
add_channel(self, map=None)
bind(self, addr)
close(self)
close_when_done(self)

  automatically close this channel once the outgoing queue is empty
collect_incoming_data(self, data)
connect(self, address)
create_socket(self, family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>)
del_channel(self, map=None)
discard_buffers(self)
found_terminator(self)
get_terminator(self)
handle_accept(self)
handle_accepted(self, sock, addr)
handle_close(self)
handle_connect(self)
handle_connect_event(self)
handle_error(self)
handle_expt(self)
handle_expt_event(self)
handle_read(self)
handle_read_event(self)
handle_write(self)
handle_write_event(self)
initiate_send(self)
listen(self, num)
log(self, message)
log_info(self, message, type='info')
push(self, data)
push_with_producer(self, producer)
readable(self)

  predicate for inclusion in the readable for select()
recv(self, buffer_size)
send(self, data)
set_reuse_addr(self)
set_socket(self, sock, map=None)
set_terminator(self, term)

  Set the input delimiter.

          Can be a fixed string of any length, an integer, or None.
        
writable(self)

  predicate for inclusion in the writable for select()
ac_in_buffer_size = 65536
ac_out_buffer_size = 65536
accepting = False
addr = None
closing = False
connected = False
connecting = False
debug = False
encoding = 'latin-1'
ignore_log_types = frozenset({'warning'})
use_encoding = 0

deque

deque([iterable[, maxlen]]) --> deque object

A list-like sequence optimized for data accesses near its endpoints.
append(...)

  Add an element to the right side of the deque.
appendleft(...)

  Add an element to the left side of the deque.
clear(...)

  Remove all elements from the deque.
copy(...)

  Return a shallow copy of a deque.
count(...)

  D.count(value) -> integer -- return number of occurrences of value
extend(...)

  Extend the right side of the deque with elements from the iterable
extendleft(...)

  Extend the left side of the deque with elements from the iterable
index(...)

  D.index(value, [start, [stop]]) -> integer -- return first index of value.
  Raises ValueError if the value is not present.
insert(...)

  D.insert(index, object) -- insert object before index
pop(...)

  Remove and return the rightmost element.
popleft(...)

  Remove and return the leftmost element.
remove(...)

  D.remove(value) -- remove first occurrence of value.
reverse(...)

  D.reverse() -- reverse *IN PLACE*
rotate(...)

  Rotate the deque n steps to the right (default n=1).  If n is negative, rotates left.
maxlen = <attribute 'maxlen' of 'collections.deque' objects>
  maximum size of a deque or None if unbounded

simple_producer

more(self)

Functions

find_prefix_at_end

find_prefix_at_end(haystack, needle)

Modules

asyncore