Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Default usage of raven.Client does not import twisted or requests #1260

Open
skrap wants to merge 6 commits into getsentry:master
base: master
Choose a base branch
Loading
from skrap:master

Conversation

@skrap
Copy link

@skrap skrap commented Jun 11, 2018
edited
Loading

This patch addresses #1258 by taking steps to lazily load the requests and twisted modules.

Summary of changes:

  • Delay the hook_libraries function if the module requested hasn't been loaded yet.
  • Remove and instead lazy load DEFAULT_TRANSPORT (wasn't used outside its .py).
  • Remove the default loading of twisted and requests in their respective transport subclasses. Lazy load what's needed.

Caveats:

  • While I modified existing tests to pass, I was not sure how to write a unit test for this, as performance tests can be tricky.
  • While this should work in all supported pythons, I'm only able to run the tests in latest 2- and 3- series.

Results:
from raven import Client takes 2.3 MB instead of 17 MB RSS.

:/tmp/raven-python# python
Python 2.7.14 (default, Jun 6 2018, 06:11:27) 
[GCC 6.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil 
>>> psutil.Process().memory_info().rss
7794688
>>> from raven import Client
>>> psutil.Process().memory_info().rss
10190848
>>> 

tonal reacted with thumbs up emoji
Copy link
Author

skrap commented Jun 12, 2018

Build failures seem unrelated to these changes:
pkg_resources.VersionConflict: (pytest 3.2.5 (/home/travis/build/getsentry/raven-python/.tox/py35-django-200-fix/lib/python3.5/site-packages), Requirement.parse('pytest>=3.6'))

Copy link
Contributor

Yup, almost have a fix ready

skrap reacted with thumbs up emoji

Copy link
Contributor

@skrap fixed, then broke again,then fixed again. Mind rebasing from master?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@ashwoods ashwoods Awaiting requested review from ashwoods

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /