mirror of
https://github.com/zulip/zulip.git
synced 2026-07-12 21:04:41 +08:00
populate_db: Request a new DB connection after run_parallel.
This is the only code change needed to make our code postgres-compatible. (imported from commit a94ad0856c46ead2892674fe18d86d49876a6160)
This commit is contained in:
parent
eea553ce40
commit
a289efb425
@ -11,7 +11,7 @@ from zephyr.models import Message, UserProfile, Stream, Recipient, Client, \
|
||||
get_huddle_hash, get_client, do_activate_user
|
||||
from zephyr.views import set_stream_color
|
||||
from zephyr.lib.parallel import run_parallel
|
||||
from django.db import transaction
|
||||
from django.db import transaction, connection
|
||||
from django.conf import settings
|
||||
from api.bots import mit_subs_list
|
||||
from zephyr.lib.bulk_create import batch_bulk_create
|
||||
@ -170,6 +170,9 @@ class Command(BaseCommand):
|
||||
jobs.append((count, personals_pairs, options, self.stdout.write))
|
||||
for status, job in run_parallel(send_messages, jobs, threads=threads):
|
||||
pass
|
||||
# Get a new database connection, after our parallel jobs
|
||||
# closed the original one
|
||||
connection.close()
|
||||
|
||||
if options["delete"]:
|
||||
# Create internal users
|
||||
@ -618,7 +621,8 @@ def restore_saved_messages():
|
||||
def send_messages(data):
|
||||
(tot_messages, personals_pairs, options, output) = data
|
||||
random.seed(os.getpid())
|
||||
from django.db import connection
|
||||
# Close the database connection, so that we get a new one that
|
||||
# isn't shared with the other threads
|
||||
connection.close()
|
||||
texts = file("zephyr/management/commands/test_messages.txt", "r").readlines()
|
||||
offset = random.randint(0, len(texts))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user