Construct EventQueues externally from ClientDescriptors

(imported from commit 7ef882074ed1c3663939da199d54e4959df8f127)
This commit is contained in:
Zev Benjamin
2013-11-19 17:11:53 -05:00
parent 968c393826
commit 06ee83b531

View File

@@ -36,7 +36,7 @@ MAX_QUEUE_TIMEOUT_SECS = 7 * 24 * 60 * 60
HEARTBEAT_MIN_FREQ_SECS = 45 HEARTBEAT_MIN_FREQ_SECS = 45
class ClientDescriptor(object): class ClientDescriptor(object):
def __init__(self, user_profile_id, realm_id, id, event_types, client_type, def __init__(self, user_profile_id, realm_id, event_queue, event_types, client_type,
apply_markdown=True, all_public_streams=False, lifespan_secs=0): apply_markdown=True, all_public_streams=False, lifespan_secs=0):
# These objects are pickled on shutdown and restored on restart. # These objects are pickled on shutdown and restored on restart.
# If fields are added or semantics are changed, temporary code must be # If fields are added or semantics are changed, temporary code must be
@@ -44,7 +44,7 @@ class ClientDescriptor(object):
self.user_profile_id = user_profile_id self.user_profile_id = user_profile_id
self.realm_id = realm_id self.realm_id = realm_id
self.current_handler = None self.current_handler = None
self.event_queue = EventQueue(id) self.event_queue = event_queue
self.queue_timeout = lifespan_secs self.queue_timeout = lifespan_secs
self.event_types = event_types self.event_types = event_types
self.last_connection_time = time.time() self.last_connection_time = time.time()
@@ -176,7 +176,7 @@ def allocate_client_descriptor(user_profile_id, realm_id, event_types, client_ty
global next_queue_id global next_queue_id
id = str(settings.SERVER_GENERATION) + ':' + str(next_queue_id) id = str(settings.SERVER_GENERATION) + ':' + str(next_queue_id)
next_queue_id += 1 next_queue_id += 1
client = ClientDescriptor(user_profile_id, realm_id, id, event_types, client_type, client = ClientDescriptor(user_profile_id, realm_id, EventQueue(id), event_types, client_type,
apply_markdown, all_public_streams, lifespan_secs) apply_markdown, all_public_streams, lifespan_secs)
clients[id] = client clients[id] = client
user_clients.setdefault(user_profile_id, []).append(client) user_clients.setdefault(user_profile_id, []).append(client)