Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZEO
Commits
c73a10e4
Commit
c73a10e4
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
64dc0c8b
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 @
c73a10e4
...
@@ -91,17 +91,20 @@ def start_zeo_server(conf, addr=None, ro_svr=0, monitor=0, keep=0, invq=None,
...
@@ -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
)
pid
=
os
.
spawnve
(
os
.
P_NOWAIT
,
sys
.
executable
,
tuple
(
args
),
d
)
adminaddr
=
(
'localhost'
,
port
+
1
)
adminaddr
=
(
'localhost'
,
port
+
1
)
# We need to wait until the server starts, but not forever
# We need to wait until the server starts, but not forever
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
for
i
in
range
(
10
):
for
i
in
range
(
5
):
time
.
sleep
(
0.25
)
try
:
try
:
zLOG
.
LOG
(
'forker'
,
zLOG
.
DEBUG
,
'connect %s'
%
i
)
zLOG
.
LOG
(
'forker'
,
zLOG
.
DEBUG
,
'connect %s'
%
i
)
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
s
.
connect
(
adminaddr
)
s
.
connect
(
adminaddr
)
ack
=
s
.
recv
(
1024
)
ack
=
s
.
recv
(
1024
)
s
.
close
()
zLOG
.
LOG
(
'forker'
,
zLOG
.
DEBUG
,
'acked: %s'
%
ack
)
zLOG
.
LOG
(
'forker'
,
zLOG
.
DEBUG
,
'acked: %s'
%
ack
)
break
break
except
socket
.
error
,
e
:
except
socket
.
error
,
e
:
if
e
[
0
]
<>
errno
.
ECONNREFUSED
:
raise
if
e
[
0
]
not
in
(
errno
.
ECONNREFUSED
,
errno
.
ECONNRESET
):
time
.
sleep
(
1
)
raise
s
.
close
()
else
:
else
:
zLOG
.
LOG
(
'forker'
,
zLOG
.
DEBUG
,
'boo hoo'
)
zLOG
.
LOG
(
'forker'
,
zLOG
.
DEBUG
,
'boo hoo'
)
raise
raise
...
...
src/ZEO/tests/zeoserver.py
View file @
c73a10e4
...
@@ -71,6 +71,7 @@ class ZEOTestServer(asyncore.dispatcher):
...
@@ -71,6 +71,7 @@ class ZEOTestServer(asyncore.dispatcher):
def
__init__
(
self
,
addr
,
server
,
keep
):
def
__init__
(
self
,
addr
,
server
,
keep
):
self
.
__super_init
()
self
.
__super_init
()
self
.
_server
=
server
self
.
_server
=
server
self
.
_sockets
=
[
self
]
self
.
_keep
=
keep
self
.
_keep
=
keep
# Count down to zero, the number of connects
# Count down to zero, the number of connects
self
.
_count
=
1
self
.
_count
=
1
...
@@ -105,11 +106,22 @@ class ZEOTestServer(asyncore.dispatcher):
...
@@ -105,11 +106,22 @@ class ZEOTestServer(asyncore.dispatcher):
for
storage
in
self
.
_server
.
storages
.
values
():
for
storage
in
self
.
_server
.
storages
.
values
():
cleanup
(
storage
)
cleanup
(
storage
)
self
.
log
(
'exiting'
)
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
)
os
.
_exit
(
0
)
self
.
log
(
'continuing'
)
self
.
log
(
'continuing'
)
sock
.
send
(
'X'
)
sock
.
send
(
'X'
)
self
.
_count
-=
1
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
):
class
Suicide
(
threading
.
Thread
):
def
__init__
(
self
,
addr
):
def
__init__
(
self
,
addr
):
...
@@ -118,7 +130,8 @@ class Suicide(threading.Thread):
...
@@ -118,7 +130,8 @@ class Suicide(threading.Thread):
def
run
(
self
):
def
run
(
self
):
# If this process doesn't exit in 60 seconds, commit suicide
# 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
from
ZEO.tests.forker
import
shutdown_zeo_server
# XXX If the -k option was given to zeoserver, then the process will
# XXX If the -k option was given to zeoserver, then the process will
# go away but the temp files won't get cleaned up.
# go away but the temp files won't get cleaned up.
...
@@ -177,6 +190,7 @@ def main():
...
@@ -177,6 +190,7 @@ def main():
storage
.
close
()
storage
.
close
()
cleanup
(
storage
)
cleanup
(
storage
)
sys
.
exit
(
2
)
sys
.
exit
(
2
)
t
.
register_socket
(
serv
.
dispatcher
)
# Create daemon suicide thread
# Create daemon suicide thread
d
=
Suicide
(
test_addr
)
d
=
Suicide
(
test_addr
)
d
.
setDaemon
(
1
)
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