Module Expr Str ImportFrom alias alias alias Import alias Import alias identifier ImportFrom alias ImportFrom alias Import alias ImportFrom alias ImportFrom alias alias alias Assign NameStore Call NameLoad Str Str Assign NameStore Call NameLoad Str Str Assign NameStore Call NameLoad Str Str Assign NameStore Num ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Num Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Num While BoolOpAnd NameLoad CompareLt NameLoad NameLoad body For TupleStore NameStore NameStore NameLoad body If UnaryOpNot BinOpBitAnd NameLoad AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call NameLoad Assign TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If CompareEq NameLoad AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call NameLoad orelse If CompareIn NameLoad TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Pass orelse AugAssignAdd NameStore Num Expr Call AttributeLoad NameLoad attr AttributeLoad AttributeLoad NameLoad attr attr Call NameLoad AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Num If CompareGtE NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr Str decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body If AttributeLoad NameLoad attr body Return Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Assign NameStore BinOpBitOr BinOpBitOr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body If UnaryOpNot AttributeLoad NameLoad attr body Return Expr Call AttributeLoad NameLoad attr Str AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body If UnaryOpNot AttributeLoad NameLoad attr body Return TryExcept body Expr Call AttributeLoad NameLoad attr handlers ExceptHandler type NameLoad name NameStore body Expr Call AttributeLoad NameLoad attr Str NameLoad Expr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call NameLoad Raise Expr Call AttributeLoad NameLoad attr Call NameLoad keyword Num decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Str Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Assign NameStore Call AttributeLoad Dict NameLoad NameLoad NameLoad NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr attr Call NameLoad NameLoad NameLoad If CompareIs NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr Str NameLoad NameLoad Return Expr Call NameLoad NameLoad NameLoad decorator_list decorator_list
N/A N/A 
A generic websocket client wrapped in an Actor

Requires thespian (of course) and websocket packages.

Linux-specific due to use of epoll(); can be changed to use select()
fairly easily, but performance will suffer

 __future__ absolute_import division print_function N/A select N/A logging log datetime timedelta collections namedtuple N/A websocket websocket ABNF thespian.actors ActorExitRequest WakeupMessage Actor N/A Start_Websocket N/A namedtuple Start_Websocket ws_addr start_msg upstream N/A Websocket_Output N/A namedtuple Websocket_Output msg N/A Websocket_Input N/A namedtuple Websocket_Input msg N/A MAX_MSGS_PER_READ 50 WebsocketClientActor N/A Actor N/A N/A 
    A websocket client wrapped in an Actor

    This was originally written to support fetching streaming data via
    a websocket; the Websocket_Input bits are less stress-tested.

    Usage:

        start_msg = "subscribe"
        ws_addr = "wss://ws-feed.somesite.com"
        startmsg = Start_Websocket(ws_addr, start_msg, receipient_Actor)
        self.client = self.createActor(WebsocketClientActor)
        self.send(self.client, startmsg)

    ...and recipient_Actor will start receiveing Websocket_Output messages

     __init__ N/A N/A self N/A N/A N/A N/A N/A N/A super WebsocketClientActor self __init__ N/A N/A self started False N/A N/A self running False N/A N/A self ws None N/A check_websocket N/A N/A self N/A N/A N/A msgs 0 N/A events N/A N/A N/A self epoll poll 0 N/A N/A events N/A msgs MAX_MSGS_PER_READ N/A N/A N/A fileno event events N/A N/A N/A N/A event N/A select EPOLLIN N/A N/A N/A N/A self send N/A self myAddress N/A ActorExitRequest N/A N/A op_code frame N/A N/A N/A self ws recv_data_frame True N/A N/A op_code N/A ABNF OPCODE_CLOSE N/A N/A N/A N/A self send N/A self myAddress N/A ActorExitRequest N/A N/A N/A op_code N/A N/A ABNF OPCODE_PING N/A ABNF OPCODE_PONG N/A ABNF OPCODE_CONT N/A N/A N/A N/A msgs 1 N/A N/A N/A self send N/A N/A self config upstream N/A Websocket_Output N/A frame data N/A events N/A N/A N/A self epoll poll 0 N/A N/A msgs MAX_MSGS_PER_READ N/A N/A N/A N/A log critical WebsocketClientActor not keeping up with incoming websocket data N/A receiveMsg_Start_Websocket N/A N/A self m sender N/A N/A N/A N/A self started N/A N/A N/A N/A self config m N/A N/A self started True N/A N/A self running True N/A N/A N/A websocket enableTrace False N/A N/A self ws N/A N/A websocket create_connection N/A m ws_addr N/A N/A N/A log info Websocket Connected N/A N/A self epoll N/A N/A select epoll N/A mask N/A N/A N/A select EPOLLIN N/A select EPOLLHUP N/A select EPOLLERR N/A N/A N/A N/A self epoll register N/A N/A N/A N/A self ws sock fileno mask N/A N/A N/A N/A self ws send N/A m start_msg N/A N/A N/A self send N/A self myAddress N/A WakeupMessage None N/A receiveMsg_Websocket_Input N/A N/A self m sender N/A N/A N/A N/A N/A self running N/A N/A N/A N/A N/A log debug Websocket sending %r N/A m msg N/A N/A N/A N/A self ws send N/A m msg N/A receiveMsg_WakeupMessage N/A N/A self m sender N/A N/A N/A N/A N/A self running N/A N/A N/A N/A N/A N/A N/A self check_websocket N/A N/A N/A Exception N/A e N/A N/A N/A N/A log error Got exception: %r e N/A N/A N/A self send N/A self myAddress N/A ActorExitRequest N/A N/A N/A N/A self wakeupAfter N/A timedelta milliseconds 20 N/A receiveMsg_ActorExitRequest N/A N/A self m sender N/A N/A N/A Stop the Websocket, and the actor N/A N/A N/A log info Websocket exiting N/A N/A self running False N/A N/A N/A N/A self epoll close N/A N/A N/A N/A self ws close N/A receiveMessage N/A N/A self m sender N/A N/A N/A handler N/A N/A N/A WakeupMessage Start_Websocket Websocket_Input ActorExitRequest N/A self receiveMsg_WakeupMessage N/A self receiveMsg_Start_Websocket N/A self receiveMsg_Websocket_Input N/A self receiveMsg_ActorExitRequest get N/A type m None N/A N/A handler None N/A N/A N/A N/A log error Unhandled message %r from %r m sender N/A N/A N/A handler m sender N/A N/A