Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
bfccb35b
Commit
bfccb35b
authored
Jun 29, 2003
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add settrace() and setprofile() functions to the threading library.
parent
c98ccfd2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
Doc/lib/libthreading.tex
Doc/lib/libthreading.tex
+14
-0
Lib/threading.py
Lib/threading.py
+20
-0
No files found.
Doc/lib/libthreading.tex
View file @
bfccb35b
...
...
@@ -90,6 +90,20 @@ subclassed in a limited fashion.
A thread that executes a function after a specified interval has passed.
\end{classdesc*}
\begin{funcdesc}
{
settrace
}{
func
}
Set a trace function
\index
{
trace function
}
for all threads started
from the
\module
{
threading
}
module. The
\var
{
func
}
will be passed to
\cfuntion
{
sys.settrace
}
for each thread, before its
\method
{
run
}
method is called.
\end{funcdesc}
\begin{funcdesc}
{
setprofile
}{
func
}
Set a profile function
\index
{
profile function
}
for all threads started
from the
\module
{
threading
}
module. The
\var
{
func
}
will be passed to
\cfuntion
{
sys.setprofile
}
for each thread, before its
\method
{
run
}
method is called.
\end{funcdesc}
Detailed interfaces for the objects are documented below.
The design of this module is loosely based on Java's threading model.
...
...
Lib/threading.py
View file @
bfccb35b
...
...
@@ -52,6 +52,18 @@ else:
def
_note
(
self
,
*
args
):
pass
# Support for profile and trace hooks
_profile_hook
=
None
_trace_hook
=
None
def
setprofile
(
func
):
global
_profile_hook
_profile_hook
=
func
def
settrace
(
func
):
global
_trace_hook
_trace_hook
=
func
# Synchronization classes
...
...
@@ -408,6 +420,14 @@ class Thread(_Verbose):
_active_limbo_lock
.
release
()
if
__debug__
:
self
.
_note
(
"%s.__bootstrap(): thread started"
,
self
)
if
_trace_hook
:
self
.
_note
(
"%s.__bootstrap(): registering trace hook"
,
self
)
_sys
.
settrace
(
_trace_hook
)
if
_profile_hook
:
self
.
_note
(
"%s.__bootstrap(): registering profile hook"
,
self
)
_sys
.
setprofile
(
_profile_hook
)
try
:
self
.
run
()
except
SystemExit
:
...
...
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