asyncore
index
/usr/local/lib/python2.4/asyncore.py
Module Docs

Basic infrastructure for asynchronous socket service clients and servers.
 
There are only two ways to have a program on a single processor do "more
than one thing at a time".  Multi-threaded programming is the simplest and
most popular way to do it, but there is another very different technique,
that lets you have nearly all the advantages of multi-threading, without
actually using multiple threads. it's really only practical if your program
is largely I/O bound. If your program is CPU bound, then pre-emptive
scheduled threads are probably what you really need. Network servers are
rarely CPU-bound, however.
 
If your operating system supports the select() system call in its I/O
library (and nearly all do), then you can use it to juggle multiple
communication channels at once; doing other work while your I/O is taking
place in the "background."  Although this strategy can seem strange and
complex, especially at first, it is in many ways easier to understand and
control than multi-threaded programming. The module documented here solves
many of the difficult problems for you, making the task of building
sophisticated high-performance network servers and clients a snap.

 
Modules
       
exceptions
fcntl
os
select
socket
sys
time

 
Classes
       
dispatcher
dispatcher_with_send
file_dispatcher
file_wrapper
exceptions.Exception
ExitNow

 
class ExitNow(exceptions.Exception)
     Methods inherited from exceptions.Exception:
__getitem__(...)
__init__(...)
__str__(...)

 
class dispatcher
     Methods defined here:
__getattr__(self, attr)
# cheap inheritance, used to pass all other attribute
# references to the underlying socket object.
__init__(self, sock=None, map=None)
__repr__(self)
accept(self)
add_channel(self, map=None)
bind(self, addr)
close(self)
connect(self, address)
create_socket(self, family, type)
del_channel(self, map=None)
handle_accept(self)
handle_close(self)
handle_connect(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)
listen(self, num)
log(self, message)
log_info(self, message, type='info')
readable(self)
recv(self, buffer_size)
send(self, data)
set_reuse_addr(self)
set_socket(self, sock, map=None)
writable(self)

Data and other attributes defined here:
accepting = False
addr = None
closing = False
connected = False
debug = False

 
class dispatcher_with_send(dispatcher)
     Methods defined here:
__init__(self, sock=None, map=None)
handle_write(self)
initiate_send(self)
send(self, data)
writable(self)

Methods inherited from dispatcher:
__getattr__(self, attr)
# cheap inheritance, used to pass all other attribute
# references to the underlying socket object.
__repr__(self)
accept(self)
add_channel(self, map=None)
bind(self, addr)
close(self)
connect(self, address)
create_socket(self, family, type)
del_channel(self, map=None)
handle_accept(self)
handle_close(self)
handle_connect(self)
handle_error(self)
handle_expt(self)
handle_expt_event(self)
handle_read(self)
handle_read_event(self)
handle_write_event(self)
listen(self, num)
log(self, message)
log_info(self, message, type='info')
readable(self)
recv(self, buffer_size)
set_reuse_addr(self)
set_socket(self, sock, map=None)

Data and other attributes inherited from dispatcher:
accepting = False
addr = None
closing = False
connected = False
debug = False

 
class file_dispatcher(dispatcher)
     Methods defined here:
__init__(self, fd, map=None)
set_file(self, fd)

Methods inherited from dispatcher:
__getattr__(self, attr)
# cheap inheritance, used to pass all other attribute
# references to the underlying socket object.
__repr__(self)
accept(self)
add_channel(self, map=None)
bind(self, addr)
close(self)
connect(self, address)
create_socket(self, family, type)
del_channel(self, map=None)
handle_accept(self)
handle_close(self)
handle_connect(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)
listen(self, num)
log(self, message)
log_info(self, message, type='info')
readable(self)
recv(self, buffer_size)
send(self, data)
set_reuse_addr(self)
set_socket(self, sock, map=None)
writable(self)

Data and other attributes inherited from dispatcher:
accepting = False
addr = None
closing = False
connected = False
debug = False

 
class file_wrapper
     Methods defined here:
__init__(self, fd)
close(self)
fileno(self)
read = recv(self, *args)
recv(self, *args)
send(self, *args)
write = send(self, *args)

 
Functions
       
close_all(map=None)
compact_traceback()
loop(timeout=30.0, use_poll=False, map=None, count=None)
poll(timeout=0.0, map=None)
poll2(timeout=0.0, map=None)
poll3 = poll2(timeout=0.0, map=None)
read(obj)
readwrite(obj, flags)
write(obj)

 
Data
        EALREADY = 114
ECONNRESET = 104
EINPROGRESS = 115
EINTR = 4
EISCONN = 106
ENOTCONN = 107
ESHUTDOWN = 108
EWOULDBLOCK = 11
errorcode = {1: 'EPERM', 2: 'ENOENT', 3: 'ESRCH', 4: 'EINTR', 5: 'EIO', 6: 'ENXIO', 7: 'E2BIG', 8: 'ENOEXEC', 9: 'EBADF', 10: 'ECHILD', ...}
socket_map = {}