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
239f138a
Commit
239f138a
authored
Feb 06, 2010
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make waiting for the server to start robust
parent
26a1f726
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
11 deletions
+19
-11
Lib/logging/config.py
Lib/logging/config.py
+18
-10
Lib/test/test_logging.py
Lib/test/test_logging.py
+1
-1
No files found.
Lib/logging/config.py
View file @
239f138a
...
...
@@ -843,17 +843,25 @@ def listen(port=DEFAULT_LOGGING_CONFIG_PORT):
abort
=
self
.
abort
logging
.
_releaseLock
()
def
serve
(
rcvr
,
hdlr
,
port
):
server
=
rcvr
(
port
=
port
,
handler
=
hdlr
)
global
_listener
logging
.
_acquireLock
()
_listener
=
server
logging
.
_releaseLock
()
server
.
serve_until_stopped
()
class
Server
(
threading
.
Thread
):
def
__init__
(
self
,
rcvr
,
hdlr
,
port
):
super
(
Server
,
self
).
__init__
()
self
.
rcvr
=
rcvr
self
.
hdlr
=
hdlr
self
.
port
=
port
self
.
ready
=
threading
.
Event
()
def
run
(
self
):
server
=
self
.
rcvr
(
port
=
self
.
port
,
handler
=
self
.
hdlr
)
self
.
ready
.
set
()
global
_listener
logging
.
_acquireLock
()
_listener
=
server
logging
.
_releaseLock
()
server
.
serve_until_stopped
()
return
threading
.
Thread
(
target
=
serve
,
args
=
(
ConfigSocketReceiver
,
ConfigStreamHandler
,
port
))
return
Server
(
ConfigSocketReceiver
,
ConfigStreamHandler
,
port
)
def
stopListening
():
"""
...
...
Lib/test/test_logging.py
View file @
239f138a
...
...
@@ -1574,7 +1574,7 @@ class ConfigDictTest(BaseTest):
port = find_unused_port()
t = logging.config.listen(port)
t.start()
t
ime.sleep(0.5) # give server thread some time to get ready
t
.ready.wait()
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(2.0)
...
...
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