pybitmessage.network.asyncore_pollchoose module¶
Basic infrastructure for asynchronous socket service clients and servers.
-
exception
ExitNow
[source]¶ Bases:
exceptions.Exception
We don’t use directly but may be necessary as we replace asyncore due to some library raising or expecting it
-
select_poller
(timeout=0.0, map=None)[source]¶ A poller which uses select(), available on most platforms.
-
epoll_poller
(timeout=0.0, map=None)[source]¶ A poller which uses epoll(), supported on Linux 2.5.44 and newer.
-
loop
(timeout=30.0, use_poll=False, map=None, count=None, poller=None)[source]¶ Poll in a loop, until count or timeout is reached
-
class
dispatcher
(sock=None, map=None)[source]¶ Bases:
object
Dispatcher for socket objects
-
debug
= False¶
-
accepting
= False¶
-
connecting
= False¶
-
closing
= False¶
-
ignore_log_types
= frozenset(['warning'])¶
-
poller_registered
= False¶
-
poller_flags
= 0¶
-
minTx
= 1500¶
-
addr
= None¶
-
connected
= False¶
-
add_channel
(map=None)¶ Add a channel
-
del_channel
(map=None)¶ Delete a channel
-
create_socket
(family=2, socket_type=1)¶ Create a socket
-
set_socket
(sock, map=None)¶ Set socket
-
set_reuse_addr
()¶ try to re-use a server port if possible
-
readable
()¶ Predicate to indicate download throttle status
-
writable
()¶ Predicate to indicate upload throttle status
-
listen
(num)¶ Listen on a port
-
bind
(addr)¶ Bind to an address
-
connect
(address)¶ Connect to an address
-
accept
()¶ Accept incoming connections. Returns either an address pair or None.
-
send
(data)¶ Send data
-
recv
(buffer_size)¶ Receive data
-
close
()¶ Close connection
-
log
(message)¶ Log a message to stderr
-
log_info
(message, log_type='info')¶ Conditionally print a message
-
handle_read_event
()¶ Handle a read event
-
handle_connect_event
()¶ Handle a connection event
-
handle_write_event
()¶ Handle a write event
-
handle_expt_event
()¶ Handle expected exceptions
-
handle_error
()¶ Handle unexpected exceptions
-
handle_accept
()¶ Handle an accept event
-
handle_expt
()¶ Log that the subclass does not implement handle_expt
-
handle_read
()¶ Log that the subclass does not implement handle_read
-
handle_write
()¶ Log that the subclass does not implement handle_write
-
handle_connect
()¶ Log that the subclass does not implement handle_connect
-
handle_accepted
(sock, addr)¶ Log that the subclass does not implement handle_accepted
-
handle_close
()¶ Log that the subclass does not implement handle_close
-
-
class
dispatcher_with_send
(sock=None, map=None)[source]¶ Bases:
pybitmessage.network.asyncore_pollchoose.dispatcher
adds simple buffered output capability, useful for simple clients. [for more sophisticated usage use asynchat.async_chat]
-
initiate_send
()¶ Initiate a send
-
handle_write
()¶ Handle a write event
-
writable
()¶ Predicate to indicate if the object is writable
-
send
(data)¶ Send data
-
-
class
file_wrapper
(fd)[source]¶ Here we override just enough to make a file look like a socket for the purposes of asyncore.
The passed fd is automatically os.dup()’d
-
recv
(*args)¶ Fake recv()
-
send
(*args)¶ Fake send()
-
getsockopt
(level, optname, buflen=None)¶ Fake getsockopt()
-
read
(*args)¶ Fake recv()
-
write
(*args)¶ Fake send()
-
close
()¶ Fake close()
-
fileno
()¶ Fake fileno()
-
-
class
file_dispatcher
(fd, map=None)[source]¶ Bases:
pybitmessage.network.asyncore_pollchoose.dispatcher
A dispatcher for file_wrapper objects
-
set_file
(fd)¶ Set file
-