-
Notifications
You must be signed in to change notification settings - Fork 5
Serverpool Doublequeue
The DQ is a class that contains two Queue.Queue objects and some additional functions and tools to allow efficient, bidirectional thread-safe communication. When using them, you have to decide up front whether the end of the connection you're coding is the server end or the client end. They act the same, but can't be used interchangeably unless you want bugs in your code. Even if the decision is arbitrary, one end must be server, the other end must be client.
When calling the helper functions, remember that the prefix is the end you're calling from, not to. So my server will use the functions server_push, server_pull, and server_notify. My client will use the client versions.
The notify functions are totally optional, but can improve the efficiency of your program if used in smart ways. Just remember that the callback will run in the opposite end's thread while they call their push function, not in your own thread.
Methods:
* __init__() # Initializes properties, which should be off-limits for code outside this class.
* client_push(obj, timeout=None) # Sends obj to the server
* client_pull(timeout=None) # retrieve an object from the server
* client_notify(callback) # set a function to be called whenever the server sends new data to the client.
* server_push(obj, timeout=None) # Sends obj to the client
* server_pull(timeout=None) # retrieve an object from the client
* server_notify(callback) # set a function to be called whenever the client sends new data to the server.
Properties:
* server # Queue for server end
* client # Queue for client end