Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
ZODB
Commits
0d767328
Commit
0d767328
authored
Jan 27, 2003
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport changes from ZODB4.
Explicitly close sockets to make tests run faster.
parent
f556d60e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
5 deletions
+22
-5
src/ZEO/tests/forker.py
src/ZEO/tests/forker.py
+7
-4
src/ZEO/tests/zeoserver.py
src/ZEO/tests/zeoserver.py
+15
-1
No files found.
src/ZEO/tests/forker.py
View file @
0d767328
...
...
@@ -91,17 +91,20 @@ def start_zeo_server(conf, addr=None, ro_svr=0, monitor=0, keep=0, invq=None,
pid
=
os
.
spawnve
(
os
.
P_NOWAIT
,
sys
.
executable
,
tuple
(
args
),
d
)
adminaddr
=
(
'localhost'
,
port
+
1
)
# We need to wait until the server starts, but not forever
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
for
i
in
range
(
5
):
for
i
in
range
(
10
):
time
.
sleep
(
0.25
)
try
:
zLOG
.
LOG
(
'forker'
,
zLOG
.
DEBUG
,
'connect %s'
%
i
)
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
.
connect
(
adminaddr
)
ack
=
s
.
recv
(
1024
)
s
.
close
()
zLOG
.
LOG
(
'forker'
,
zLOG
.
DEBUG
,
'acked: %s'
%
ack
)
break
except
socket
.
error
,
e
:
if
e
[
0
]
<>
errno
.
ECONNREFUSED
:
raise
time
.
sleep
(
1
)
if
e
[
0
]
not
in
(
errno
.
ECONNREFUSED
,
errno
.
ECONNRESET
):
raise
s
.
close
()
else
:
zLOG
.
LOG
(
'forker'
,
zLOG
.
DEBUG
,
'boo hoo'
)
raise
...
...
src/ZEO/tests/zeoserver.py
View file @
0d767328
...
...
@@ -71,6 +71,7 @@ class ZEOTestServer(asyncore.dispatcher):
def
__init__
(
self
,
addr
,
server
,
keep
):
self
.
__super_init
()
self
.
_server
=
server
self
.
_sockets
=
[
self
]
self
.
_keep
=
keep
# Count down to zero, the number of connects
self
.
_count
=
1
...
...
@@ -105,11 +106,22 @@ class ZEOTestServer(asyncore.dispatcher):
for
storage
in
self
.
_server
.
storages
.
values
():
cleanup
(
storage
)
self
.
log
(
'exiting'
)
# Close all the other sockets so that we don't have to wait
# for os._exit() to get to it before starting the next
# server process.
for
s
in
self
.
_sockets
:
s
.
close
()
# Now explicitly close the socket returned from accept(),
# since it didn't go through the wrapper.
sock
.
close
()
os
.
_exit
(
0
)
self
.
log
(
'continuing'
)
sock
.
send
(
'X'
)
self
.
_count
-=
1
def
register_socket
(
self
,
sock
):
# Register a socket to be closed when server shutsdown.
self
.
_sockets
.
append
(
sock
)
class
Suicide
(
threading
.
Thread
):
def
__init__
(
self
,
addr
):
...
...
@@ -118,7 +130,8 @@ class Suicide(threading.Thread):
def
run
(
self
):
# If this process doesn't exit in 60 seconds, commit suicide
time
.
sleep
(
60
)
for
i
in
range
(
20
):
time
.
sleep
(
5
)
from
ZEO.tests.forker
import
shutdown_zeo_server
# XXX If the -k option was given to zeoserver, then the process will
# go away but the temp files won't get cleaned up.
...
...
@@ -177,6 +190,7 @@ def main():
storage
.
close
()
cleanup
(
storage
)
sys
.
exit
(
2
)
t
.
register_socket
(
serv
.
dispatcher
)
# Create daemon suicide thread
d
=
Suicide
(
test_addr
)
d
.
setDaemon
(
1
)
...
...
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