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
a9b2222d
Commit
a9b2222d
authored
Aug 18, 2008
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change a few uses of the threading APIs
parent
cbae8697
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
16 deletions
+16
-16
Lib/logging/__init__.py
Lib/logging/__init__.py
+1
-1
Lib/multiprocessing/managers.py
Lib/multiprocessing/managers.py
+8
-8
Lib/multiprocessing/queues.py
Lib/multiprocessing/queues.py
+1
-1
Lib/test/test_dummy_threading.py
Lib/test/test_dummy_threading.py
+3
-3
Lib/test/test_multiprocessing.py
Lib/test/test_multiprocessing.py
+2
-2
Lib/test/test_socketserver.py
Lib/test/test_socketserver.py
+1
-1
No files found.
Lib/logging/__init__.py
View file @
a9b2222d
...
@@ -262,7 +262,7 @@ class LogRecord:
...
@@ -262,7 +262,7 @@ class LogRecord:
self
.
relativeCreated
=
(
self
.
created
-
_startTime
)
*
1000
self
.
relativeCreated
=
(
self
.
created
-
_startTime
)
*
1000
if
logThreads
and
thread
:
if
logThreads
and
thread
:
self
.
thread
=
thread
.
get_ident
()
self
.
thread
=
thread
.
get_ident
()
self
.
threadName
=
threading
.
current_thread
().
get_name
()
self
.
threadName
=
threading
.
current_thread
().
name
else
:
else
:
self
.
thread
=
None
self
.
thread
=
None
self
.
threadName
=
None
self
.
threadName
=
None
...
...
Lib/multiprocessing/managers.py
View file @
a9b2222d
...
@@ -201,7 +201,7 @@ class Server(object):
...
@@ -201,7 +201,7 @@ class Server(object):
Handle requests from the proxies in a particular process/thread
Handle requests from the proxies in a particular process/thread
'''
'''
util
.
debug
(
'starting server thread to service %r'
,
util
.
debug
(
'starting server thread to service %r'
,
threading
.
current_thread
().
get_name
()
)
threading
.
current_thread
().
name
)
recv
=
conn
.
recv
recv
=
conn
.
recv
send
=
conn
.
send
send
=
conn
.
send
...
@@ -251,7 +251,7 @@ class Server(object):
...
@@ -251,7 +251,7 @@ class Server(object):
except
EOFError
:
except
EOFError
:
util
.
debug
(
'got EOF -- exiting thread serving %r'
,
util
.
debug
(
'got EOF -- exiting thread serving %r'
,
threading
.
current_thread
().
get_name
()
)
threading
.
current_thread
().
name
)
sys
.
exit
(
0
)
sys
.
exit
(
0
)
except
Exception
:
except
Exception
:
...
@@ -264,7 +264,7 @@ class Server(object):
...
@@ -264,7 +264,7 @@ class Server(object):
send
((
'#UNSERIALIZABLE'
,
repr
(
msg
)))
send
((
'#UNSERIALIZABLE'
,
repr
(
msg
)))
except
Exception
,
e
:
except
Exception
,
e
:
util
.
info
(
'exception in thread serving %r'
,
util
.
info
(
'exception in thread serving %r'
,
threading
.
current_thread
().
get_name
()
)
threading
.
current_thread
().
name
)
util
.
info
(
' ... message was %r'
,
msg
)
util
.
info
(
' ... message was %r'
,
msg
)
util
.
info
(
' ... exception was %r'
,
e
)
util
.
info
(
' ... exception was %r'
,
e
)
conn
.
close
()
conn
.
close
()
...
@@ -386,7 +386,7 @@ class Server(object):
...
@@ -386,7 +386,7 @@ class Server(object):
'''
'''
Spawn a new thread to serve this connection
Spawn a new thread to serve this connection
'''
'''
threading
.
current_thread
().
set_name
(
name
)
threading
.
current_thread
().
name
=
name
c
.
send
((
'#RETURN'
,
None
))
c
.
send
((
'#RETURN'
,
None
))
self
.
serve_client
(
c
)
self
.
serve_client
(
c
)
...
@@ -700,8 +700,8 @@ class BaseProxy(object):
...
@@ -700,8 +700,8 @@ class BaseProxy(object):
def
_connect
(
self
):
def
_connect
(
self
):
util
.
debug
(
'making connection to manager'
)
util
.
debug
(
'making connection to manager'
)
name
=
current_process
().
get_name
()
name
=
current_process
().
get_name
()
if
threading
.
current_thread
().
get_name
()
!=
'MainThread'
:
if
threading
.
current_thread
().
name
!=
'MainThread'
:
name
+=
'|'
+
threading
.
current_thread
().
get_name
()
name
+=
'|'
+
threading
.
current_thread
().
name
conn
=
self
.
_Client
(
self
.
_token
.
address
,
authkey
=
self
.
_authkey
)
conn
=
self
.
_Client
(
self
.
_token
.
address
,
authkey
=
self
.
_authkey
)
dispatch
(
conn
,
None
,
'accept_connection'
,
(
name
,))
dispatch
(
conn
,
None
,
'accept_connection'
,
(
name
,))
self
.
_tls
.
connection
=
conn
self
.
_tls
.
connection
=
conn
...
@@ -714,7 +714,7 @@ class BaseProxy(object):
...
@@ -714,7 +714,7 @@ class BaseProxy(object):
conn
=
self
.
_tls
.
connection
conn
=
self
.
_tls
.
connection
except
AttributeError
:
except
AttributeError
:
util
.
debug
(
'thread %r does not own a connection'
,
util
.
debug
(
'thread %r does not own a connection'
,
threading
.
current_thread
().
get_name
()
)
threading
.
current_thread
().
name
)
self
.
_connect
()
self
.
_connect
()
conn
=
self
.
_tls
.
connection
conn
=
self
.
_tls
.
connection
...
@@ -775,7 +775,7 @@ class BaseProxy(object):
...
@@ -775,7 +775,7 @@ class BaseProxy(object):
# the process owns no more references to objects for this manager
# the process owns no more references to objects for this manager
if
not
idset
and
hasattr
(
tls
,
'connection'
):
if
not
idset
and
hasattr
(
tls
,
'connection'
):
util
.
debug
(
'thread %r has no more proxies so closing conn'
,
util
.
debug
(
'thread %r has no more proxies so closing conn'
,
threading
.
current_thread
().
get_name
()
)
threading
.
current_thread
().
name
)
tls
.
connection
.
close
()
tls
.
connection
.
close
()
del
tls
.
connection
del
tls
.
connection
...
...
Lib/multiprocessing/queues.py
View file @
a9b2222d
...
@@ -155,7 +155,7 @@ class Queue(object):
...
@@ -155,7 +155,7 @@ class Queue(object):
self
.
_wlock
,
self
.
_writer
.
close
),
self
.
_wlock
,
self
.
_writer
.
close
),
name
=
'QueueFeederThread'
name
=
'QueueFeederThread'
)
)
self
.
_thread
.
set_daemon
(
True
)
self
.
_thread
.
daemon
=
True
debug
(
'doing self._thread.start()'
)
debug
(
'doing self._thread.start()'
)
self
.
_thread
.
start
()
self
.
_thread
.
start
()
...
...
Lib/test/test_dummy_threading.py
View file @
a9b2222d
...
@@ -16,7 +16,7 @@ class DummyThreadingTestCase(unittest.TestCase):
...
@@ -16,7 +16,7 @@ class DummyThreadingTestCase(unittest.TestCase):
#delay = random.random() * 2
#delay = random.random() * 2
delay
=
0
delay
=
0
if
test_support
.
verbose
:
if
test_support
.
verbose
:
print
'task'
,
self
.
get_name
()
,
'will run for'
,
delay
,
'sec'
print
'task'
,
self
.
name
,
'will run for'
,
delay
,
'sec'
sema
.
acquire
()
sema
.
acquire
()
mutex
.
acquire
()
mutex
.
acquire
()
running
+=
1
running
+=
1
...
@@ -25,11 +25,11 @@ class DummyThreadingTestCase(unittest.TestCase):
...
@@ -25,11 +25,11 @@ class DummyThreadingTestCase(unittest.TestCase):
mutex
.
release
()
mutex
.
release
()
time
.
sleep
(
delay
)
time
.
sleep
(
delay
)
if
test_support
.
verbose
:
if
test_support
.
verbose
:
print
'task'
,
self
.
get_name
()
,
'done'
print
'task'
,
self
.
name
,
'done'
mutex
.
acquire
()
mutex
.
acquire
()
running
-=
1
running
-=
1
if
test_support
.
verbose
:
if
test_support
.
verbose
:
print
self
.
get_name
()
,
'is finished.'
,
running
,
'tasks are running'
print
self
.
name
,
'is finished.'
,
running
,
'tasks are running'
mutex
.
release
()
mutex
.
release
()
sema
.
release
()
sema
.
release
()
...
...
Lib/test/test_multiprocessing.py
View file @
a9b2222d
...
@@ -670,7 +670,7 @@ class _TestCondition(BaseTestCase):
...
@@ -670,7 +670,7 @@ class _TestCondition(BaseTestCase):
t
=
threading
.
Thread
(
target
=
self
.
f
,
t
=
threading
.
Thread
(
target
=
self
.
f
,
args
=
(
cond
,
sleeping
,
woken
,
TIMEOUT1
))
args
=
(
cond
,
sleeping
,
woken
,
TIMEOUT1
))
t
.
set_daemon
(
True
)
t
.
daemon
=
True
t
.
start
()
t
.
start
()
# wait for them all to sleep
# wait for them all to sleep
...
@@ -692,7 +692,7 @@ class _TestCondition(BaseTestCase):
...
@@ -692,7 +692,7 @@ class _TestCondition(BaseTestCase):
p
.
start
()
p
.
start
()
t
=
threading
.
Thread
(
target
=
self
.
f
,
args
=
(
cond
,
sleeping
,
woken
))
t
=
threading
.
Thread
(
target
=
self
.
f
,
args
=
(
cond
,
sleeping
,
woken
))
t
.
set_daemon
(
True
)
t
.
daemon
=
True
t
.
start
()
t
.
start
()
# wait for them to all sleep
# wait for them to all sleep
...
...
Lib/test/test_socketserver.py
View file @
a9b2222d
...
@@ -139,7 +139,7 @@ class SocketServerTest(unittest.TestCase):
...
@@ -139,7 +139,7 @@ class SocketServerTest(unittest.TestCase):
# Time between requests is short enough that we won't wake
# Time between requests is short enough that we won't wake
# up spuriously too many times.
# up spuriously too many times.
kwargs
=
{
'poll_interval'
:
0.01
})
kwargs
=
{
'poll_interval'
:
0.01
})
t
.
set_daemon
(
True
)
# In case this function raises.
t
.
daemon
=
True
# In case this function raises.
t
.
start
()
t
.
start
()
if
verbose
:
print
"server running"
if
verbose
:
print
"server running"
for
i
in
range
(
3
):
for
i
in
range
(
3
):
...
...
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