mirror of https://github.com/zulip/zulip.git
bugdown: Lazily import python-twitter.
python-twitter was consuming a significant amount of import time. However, this commit seems to not save any time at all, probably because its recursive dependencies are imported elsewhere in Zulip.
This commit is contained in:
parent
4d07e485ff
commit
38afeb7ac2
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue