-
-
Notifications
You must be signed in to change notification settings - Fork 66
Fix import error on Windows #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Hajime Yamasaki Vukelic <hayavuk@gmail.com>
codingjoe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, that was fast! I had one tiny comment 👍
|
|
||
| class MemoryUsageWidget(progressbar.widgets.WidgetBase): | ||
| def __call__(self, progress, data): | ||
| if not resource: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if resource is not None:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, that looks better. Will fix.
First cover the more common path. Signed-off-by: Hajime Yamasaki Vukelic <hayavuk@gmail.com>
|
Branch updated. Hopefully this is along the lines of what you had in mind. |
codingjoe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my bad, I wrote it wrong. Makes no sense to switch it around. It was just about testing explicitly that it is None.
| return 'RAM: {0:10.1f} MB'.format( | ||
| resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024 | ||
| ) | ||
| if resource is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dang, I wrote it wrong.
if resource is None:
return 'RAM: N/A'
return ...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh alright. It'll be some hours before I'll be able to switch those around (day job). Though, the your first suggestion is not necessarily incorrect since it's a more common branch, likely to be hit more often in real life. Let me know if you still want them flipped.
|
Don't worry I fixed it for you: f317a04 Released in 4.2.1 Thanks!!! |
On Windows, Python does not have a
resourcemodule, which causes django-stdimage to raise anImportError(ModuleNotFoundErrorin Py3).This patch is a workaround for the issue as discussed in #127. It wraps the import in
try-exceptand disables memory usage stats in the progress bar when import fails.