Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
82cbb9a1
Commit
82cbb9a1
authored
Jan 15, 2012
by
Bridger Maxwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Matched stop and start calls in perf middleware.
parent
6e9e9c76
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
perfstats/middleware.py
+15
-5
No files found.
perfstats/middleware.py
View file @
82cbb9a1
...
...
@@ -5,17 +5,21 @@ from django.conf import settings
tmpfile
=
None
prof
=
None
isRunning
=
False
def
restart_profile
():
global
prof
,
tmpfile
global
prof
,
tmpfile
,
isRunning
try
:
oldname
=
tmpfile
.
name
except
:
oldname
=
""
if
prof
!=
None
:
if
isRunning
:
prof
.
stop
()
prof
.
close
()
tmpfile
=
tempfile
.
NamedTemporaryFile
(
prefix
=
'prof'
,
delete
=
False
)
prof
=
hotshot
.
Profile
(
tmpfile
.
name
)
prof
=
hotshot
.
Profile
(
tmpfile
.
name
,
lineevents
=
1
)
isRunning
=
False
print
"Filename"
,
tmpfile
.
name
return
(
tmpfile
.
name
,
oldname
)
...
...
@@ -23,13 +27,19 @@ restart_profile()
class
ProfileMiddleware
:
def
process_request
(
self
,
request
):
global
isRunning
if
not
isRunning
:
prof
.
start
()
isRunning
=
True
else
:
print
"Profiler was already running. Results may be unpredictable"
print
"Process request"
def
process_response
(
self
,
request
,
response
):
try
:
global
isRunning
if
isRunning
:
prof
.
stop
()
except
:
print
"Profiler not active. If you didn't just restart, this is an error"
isRunning
=
False
print
"Process response"
return
response
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment