asyncore
index
/usr/lib/python1.6/asyncore.py

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
            
FCNTL
fcntl
os
select
socket
string
sys

 
Classes
            
dispatcher
dispatcher_with_send
file_dispatcher
file_wrapper

 
class dispatcher
       
  
__getattr__(self, attr)
# cheap inheritance, used to pass all other attribute
# references to the underlying socket object.
# NOTE: this may be removed soon for performance reasons.
__init__(self, sock=None)
__repr__(self)
accept(self)
add_channel(self)
bind(self, addr)
close(self)
connect(self, address)
create_socket(self, family, type)
del_channel(self)
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)
readable(self)
recv(self, buffer_size)
send(self, data)
set_reuse_addr(self)
set_socket(self, socket)
writable(self)

 
class dispatcher_with_send(dispatcher)
       
  
__getattr__(self, attr) from dispatcher
__init__(self, sock=None)
__repr__(self) from dispatcher
accept(self) from dispatcher
add_channel(self) from dispatcher
bind(self, addr) from dispatcher
close(self) from dispatcher
connect(self, address) from dispatcher
create_socket(self, family, type) from dispatcher
del_channel(self) from dispatcher
handle_accept(self) from dispatcher
handle_close(self) from dispatcher
handle_connect(self) from dispatcher
handle_error(self) from dispatcher
handle_expt(self) from dispatcher
handle_expt_event(self) from dispatcher
handle_read(self) from dispatcher
handle_read_event(self) from dispatcher
handle_write(self)
handle_write_event(self) from dispatcher
initiate_send(self)
listen(self, num) from dispatcher
log(self, message) from dispatcher
readable(self) from dispatcher
recv(self, buffer_size) from dispatcher
send(self, data)
set_reuse_addr(self) from dispatcher
set_socket(self, socket) from dispatcher
writable(self)

 
class file_dispatcher(dispatcher)
       
  
__getattr__(self, attr) from dispatcher
__init__(self, fd)
__repr__(self) from dispatcher
accept(self) from dispatcher
add_channel(self) from dispatcher
bind(self, addr) from dispatcher
close(self) from dispatcher
connect(self, address) from dispatcher
create_socket(self, family, type) from dispatcher
del_channel(self) from dispatcher
handle_accept(self) from dispatcher
handle_close(self) from dispatcher
handle_connect(self) from dispatcher
handle_error(self) from dispatcher
handle_expt(self) from dispatcher
handle_expt_event(self) from dispatcher
handle_read(self) from dispatcher
handle_read_event(self) from dispatcher
handle_write(self) from dispatcher
handle_write_event(self) from dispatcher
listen(self, num) from dispatcher
log(self, message) from dispatcher
readable(self) from dispatcher
recv(self, buffer_size) from dispatcher
send(self, data) from dispatcher
set_file(self, fd)
set_reuse_addr(self) from dispatcher
set_socket(self, socket) from dispatcher
writable(self) from dispatcher

 
class file_wrapper
       
  
__init__(self, fd)
# here we override just enough to make a file
# look like a socket for the purposes of asyncore.
close(self)
fileno(self)
recv(self, *args)
write(self, *args)

 
Functions
            
close_all()
compact_traceback()
loop(timeout=30.0, use_poll=0)
poll(timeout=0.0)
poll2(timeout=0.0)

 
Data
             EALREADY = 114
ECONNRESET = 104
EINPROGRESS = 115
ENOTCONN = 107
ESHUTDOWN = 108
EWOULDBLOCK = 11
__file__ = '/usr/lib/python1.6/asyncore.pyc'
__name__ = 'asyncore'
socket_map = {}