💾 Archived View for tris.fyi › pydoc › asynchat captured on 2023-04-26 at 13:26:19. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
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.
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([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
more(self)
find_prefix_at_end(haystack, needle)
warn(message, category=None, stacklevel=1, source=None) Issue a warning, or maybe ignore it or raise an exception.