diff --git a/zerver/lib/bugdown/__init__.py b/zerver/lib/bugdown/__init__.py index 47d39f7a68..c74ad80a1a 100644 --- a/zerver/lib/bugdown/__init__.py +++ b/zerver/lib/bugdown/__init__.py @@ -12,7 +12,6 @@ import urllib import re import os import html -import twitter import platform import time import functools @@ -302,6 +301,11 @@ def fetch_tweet_data(tweet_id: str) -> Optional[Dict[str, Any]]: if not all(creds.values()): return None + # We lazily import twitter here because its import process is + # surprisingly slow, and doing so has a significant impact on + # the startup performance of `manage.py` commands. + import twitter + try: api = twitter.Api(tweet_mode='extended', **creds) # Sometimes Twitter hangs on responses. Timing out here