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
28c1046a
Commit
28c1046a
authored
Dec 19, 2012
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Plain Diff
Small cleanup in test_ftplib
parents
7ce98ff7
bc8da7ed
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
Lib/test/test_ftplib.py
Lib/test/test_ftplib.py
+14
-13
No files found.
Lib/test/test_ftplib.py
View file @
28c1046a
...
...
@@ -896,39 +896,40 @@ class TestTimeouts(TestCase):
def
setUp
(
self
):
self
.
evt
=
threading
.
Event
()
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
sock
.
settimeout
(
1
0
)
self
.
sock
.
settimeout
(
2
0
)
self
.
port
=
support
.
bind_port
(
self
.
sock
)
threading
.
Thread
(
target
=
self
.
server
,
args
=
(
self
.
evt
,
self
.
sock
)).
start
()
self
.
server_thread
=
threading
.
Thread
(
target
=
self
.
server
)
self
.
server_thread
.
start
()
# Wait for the server to be ready.
self
.
evt
.
wait
()
self
.
evt
.
clear
()
self
.
old_port
=
ftplib
.
FTP
.
port
ftplib
.
FTP
.
port
=
self
.
port
def
tearDown
(
self
):
self
.
evt
.
wait
()
self
.
s
ock
.
close
()
ftplib
.
FTP
.
port
=
self
.
old_port
self
.
s
erver_thread
.
join
()
def
server
(
self
,
evt
,
serv
):
def
server
(
self
):
# This method sets the evt 3 times:
# 1) when the connection is ready to be accepted.
# 2) when it is safe for the caller to close the connection
# 3) when we have closed the socket
se
rv
.
listen
(
5
)
se
lf
.
sock
.
listen
(
5
)
# (1) Signal the caller that we are ready to accept the connection.
evt
.
set
()
self
.
evt
.
set
()
try
:
conn
,
addr
=
se
rv
.
accept
()
conn
,
addr
=
se
lf
.
sock
.
accept
()
except
socket
.
timeout
:
pass
else
:
conn
.
send
(
b"1 Hola mundo
\
n
"
)
conn
.
sendall
(
b"1 Hola mundo
\
n
"
)
conn
.
shutdown
(
socket
.
SHUT_WR
)
# (2) Signal the caller that it is safe to close the socket.
evt
.
set
()
self
.
evt
.
set
()
conn
.
close
()
finally
:
serv
.
close
()
# (3) Signal the caller that we are done.
evt
.
set
()
self
.
sock
.
close
()
def
testTimeoutDefault
(
self
):
# default -- use global socket timeout
...
...
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