mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	tornado: Swap to early-abort, for fewer long hanging blocks.
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							39368cad3a
						
					
				
				
					commit
					6918556648
				
			@@ -24,7 +24,9 @@ def request_event_queue(user_profile: UserProfile, user_client: Client, apply_ma
 | 
			
		||||
                        narrow: Iterable[Sequence[str]]=[],
 | 
			
		||||
                        bulk_message_deletion: bool=False) -> Optional[str]:
 | 
			
		||||
 | 
			
		||||
    if settings.TORNADO_SERVER:
 | 
			
		||||
    if not settings.TORNADO_SERVER:
 | 
			
		||||
        return None
 | 
			
		||||
 | 
			
		||||
    tornado_uri = get_tornado_uri(user_profile.realm)
 | 
			
		||||
    req = {'dont_block': 'true',
 | 
			
		||||
           'apply_markdown': ujson.dumps(apply_markdown),
 | 
			
		||||
@@ -56,10 +58,10 @@ def request_event_queue(user_profile: UserProfile, user_client: Client, apply_ma
 | 
			
		||||
 | 
			
		||||
    return resp.json()['queue_id']
 | 
			
		||||
 | 
			
		||||
    return None
 | 
			
		||||
 | 
			
		||||
def get_user_events(user_profile: UserProfile, queue_id: str, last_event_id: int) -> List[Dict[str, Any]]:
 | 
			
		||||
    if settings.TORNADO_SERVER:
 | 
			
		||||
    if not settings.TORNADO_SERVER:
 | 
			
		||||
        return []
 | 
			
		||||
 | 
			
		||||
    tornado_uri = get_tornado_uri(user_profile.realm)
 | 
			
		||||
    post_data: Dict[str, Any] = {
 | 
			
		||||
        'queue_id': queue_id,
 | 
			
		||||
@@ -74,16 +76,15 @@ def get_user_events(user_profile: UserProfile, queue_id: str, last_event_id: int
 | 
			
		||||
    resp.raise_for_status()
 | 
			
		||||
 | 
			
		||||
    return resp.json()['events']
 | 
			
		||||
    return []
 | 
			
		||||
 | 
			
		||||
def send_notification_http(realm: Realm, data: Mapping[str, Any]) -> None:
 | 
			
		||||
    if settings.TORNADO_SERVER and not settings.RUNNING_INSIDE_TORNADO:
 | 
			
		||||
    if not settings.TORNADO_SERVER or settings.RUNNING_INSIDE_TORNADO:
 | 
			
		||||
        process_notification(data)
 | 
			
		||||
    else:
 | 
			
		||||
        tornado_uri = get_tornado_uri(realm)
 | 
			
		||||
        requests_client.post(tornado_uri + '/notify_tornado', data=dict(
 | 
			
		||||
            data   = ujson.dumps(data),
 | 
			
		||||
            secret = settings.SHARED_SECRET))
 | 
			
		||||
    else:
 | 
			
		||||
        process_notification(data)
 | 
			
		||||
 | 
			
		||||
def send_event(realm: Realm, event: Mapping[str, Any],
 | 
			
		||||
               users: Union[Iterable[int], Iterable[Mapping[str, Any]]]) -> None:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user