asyncore
index
/usr/local/lib/python2.5/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
       
fcntl
os
select
socket
sys
time

 
Classes
       
dispatcher
dispatcher_with_send
file_dispatcher
file_wrapper
exceptions.Exception(exceptions.BaseException)
ExitNow

 
class ExitNow(exceptions.Exception)
    
Method resolution order:
ExitNow
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x8125440>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message
exception message

 
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 = {}