concurrent.core.transport package

Submodules

concurrent.core.transport.api module

API for transport related modules

class concurrent.core.transport.api.IClientSocket[source]

Bases: object

Basic socket interface

close()[source]

Close socket connection

connect(host, port)[source]

Connect to a given host and port

receive(map=None)[source]

Receive data from a socket mapping the received data if required

send(data)[source]

Send data to a socket

concurrent.core.transport.gzipper module

WSGI gzip middleware adapted from: http://www.evanfosmark.com/2008/12/python-wsgi-middleware-for-automatic-gzipping/

class concurrent.core.transport.gzipper.Gzipper(app, compresslevel=6)[source]

Bases: object

WSGI middleware to wrap around and gzip all output. This automatically adds the content-encoding header.

client_wants_gzip(accept_encoding_header)[source]

Check to see if the client can accept gzipped output, and whether or not it is even the preferred method. If identity is higher, then no gzipping should occur.

gzip_string(string, compression_level)[source]

The gzip module didn’t provide a way to gzip just a string. Had to hack together this. I know, it isn’t pretty.

parse_encoding_header(header)[source]

Break up the HTTP_ACCEPT_ENCODING header into a dict of the form, {‘encoding-name’:qvalue}.

concurrent.core.transport.tcpserver module

Implementation of our socket server

concurrent.core.transport.tcpserver.tcpremote(tcp_opbject, name=None)[source]

makes TCPServer or TCPClient a decorator so that you can write :

from tcpserver import *

server = TCPServer(...)

@tcpremote(server, name=’login’) def login(request, client_address, user_name, user_pass):

(...)
class concurrent.core.transport.tcpserver.TCPHandler[source]

Bases: object

Very simple TCP protocol handler that translates incomming request to function calls

add_method(name, method)[source]
handle(handler, request, data)[source]
handle_rpc(handler, request, data)[source]
class concurrent.core.transport.tcpserver.TCPServer(host, port, master)[source]

Bases: SocketServer.ThreadingMixIn, SocketServer.TCPServer, concurrent.core.transport.tcpserver.TCPHandler

Our threaded socket implementation is a JSON-RPC implementation using a SocketServer. We use this technique to be able to achieve high-performance in connectivity and sync between all nodes while being felxible and simple within our data interaction.

allow_reuse_address = True
client_connected(request, client_address, handler)[source]
client_disconnected(request, client_address, handler)[source]
daemon_threads = True
class concurrent.core.transport.tcpserver.TCPClient(log, host, port, node, socket1=None, socket_timeout=None)[source]

Bases: concurrent.core.transport.tcpsocket.TCPSocket, concurrent.core.transport.tcpserver.TCPHandler

TCP client used to map protocol calling mechanisms to a given function. Just a special socket that does apart from sending and receiving the translation of our protocol.

close()[source]

Close socket connection and client thread

connect()[source]

Connect and start the client thread to listen for responses

concurrent.core.transport.tcpsocket module

Simple base socket system used in transport protocol based systems

class concurrent.core.transport.tcpsocket.IClientSocket

Bases: object

Basic socket interface

close()

Close socket connection

connect(host, port)

Connect to a given host and port

receive(map=None)

Receive data from a socket mapping the received data if required

send(data)

Send data to a socket

concurrent.core.transport.tcpsocket.send_to(sock, method, *args, **kwargs)[source]

Send data to a given socket

concurrent.core.transport.tcpsocket.receive_from(sock, map=None)[source]

Receive data from a give socket

Module contents