mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	import_realm: Close the memcached connection before forking.
This prevents the memcached connection from being shared across multiple processes, and hopefully addresses unexpected behavior from cached functions like get_user_profile_by_id invoked inside the worker processes. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							cf5ededa35
						
					
				
				
					commit
					46babbe9e1
				
			@@ -10,6 +10,7 @@ import boto3
 | 
			
		||||
import orjson
 | 
			
		||||
from bs4 import BeautifulSoup
 | 
			
		||||
from django.conf import settings
 | 
			
		||||
from django.core.cache import cache
 | 
			
		||||
from django.db import connection
 | 
			
		||||
from django.db.models import Max
 | 
			
		||||
from django.utils.timezone import now as timezone_now
 | 
			
		||||
@@ -759,6 +760,7 @@ def import_uploads(realm: Realm, import_dir: Path, processes: int, processing_av
 | 
			
		||||
                process_avatars(record)
 | 
			
		||||
        else:
 | 
			
		||||
            connection.close()
 | 
			
		||||
            cache._cache.disconnect_all()
 | 
			
		||||
            with multiprocessing.Pool(processes) as p:
 | 
			
		||||
                for out in p.imap_unordered(process_avatars, records):
 | 
			
		||||
                    pass
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user