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
2224b1aa
Commit
2224b1aa
authored
May 08, 2001
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add run_server() method and profile support from ZEO2
parent
a2b3f6f6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
15 deletions
+31
-15
src/ZEO/tests/forker.py
src/ZEO/tests/forker.py
+31
-15
No files found.
src/ZEO/tests/forker.py
View file @
2224b1aa
"""Library for forking storage server and connecting client storage"""
"""Library for forking storage server and connecting client storage"""
import
asyncore
import
asyncore
import
atexit
import
os
import
os
import
profile
import
sys
import
sys
import
time
import
types
import
ThreadedAsync
import
ThreadedAsync
import
ZEO.ClientStorage
,
ZEO
.
StorageServer
import
ZEO.ClientStorage
,
ZEO
.
StorageServer
PROFILE
=
0
class
ZEOServerExit
(
asyncore
.
file_dispatcher
):
class
ZEOServerExit
(
asyncore
.
file_dispatcher
):
"""Used to exit ZEO.StorageServer when run is done"""
"""Used to exit ZEO.StorageServer when run is done"""
...
@@ -36,24 +42,30 @@ def start_zeo_server(storage, addr):
...
@@ -36,24 +42,30 @@ def start_zeo_server(storage, addr):
rd
,
wr
=
os
.
pipe
()
rd
,
wr
=
os
.
pipe
()
pid
=
os
.
fork
()
pid
=
os
.
fork
()
if
pid
==
0
:
if
pid
==
0
:
if
PROFILE
:
p
=
profile
.
Profile
()
p
.
runctx
(
"run_server(storage, addr, rd, wr)"
,
globals
(),
locals
())
p
.
dump_stats
(
"stats.s.%d"
%
os
.
getpid
())
else
:
run_server
(
storage
,
addr
,
rd
,
wr
)
os
.
_exit
(
0
)
else
:
os
.
close
(
rd
)
return
pid
,
ZEOClientExit
(
wr
)
def
run_server
(
storage
,
addr
,
rd
,
wr
):
# in the child, run the storage server
# in the child, run the storage server
try
:
os
.
close
(
wr
)
os
.
close
(
wr
)
ZEOServerExit
(
rd
)
ZEOServerExit
(
rd
)
serv
=
ZEO
.
StorageServer
.
StorageServer
(
addr
,
{
'1'
:
storage
})
serv
=
ZEO
.
StorageServer
.
StorageServer
(
addr
,
{
'1'
:
storage
})
asyncore
.
loop
()
asyncore
.
loop
()
storage
.
close
()
storage
.
close
()
if
domain
==
"AF_UNIX"
:
if
isinstance
(
addr
,
types
.
StringType
)
:
os
.
unlink
(
addr
)
os
.
unlink
(
addr
)
if
cleanup
:
cleanup
()
finally
:
os
.
_exit
(
0
)
else
:
os
.
close
(
rd
)
return
pid
,
ZEOClientExit
(
wr
)
def
start_zeo
(
storage
,
cache
=
None
,
cleanup
=
None
,
domain
=
"AF_INET"
):
def
start_zeo
(
storage
,
cache
=
None
,
cleanup
=
None
,
domain
=
"AF_INET"
,
storage_id
=
"1"
):
"""Setup ZEO client-server for storage.
"""Setup ZEO client-server for storage.
Returns a ClientStorage instance and a ZEOClientExit instance.
Returns a ClientStorage instance and a ZEOClientExit instance.
...
@@ -71,6 +83,10 @@ def start_zeo(storage, cache=None, cleanup=None, domain="AF_INET"):
...
@@ -71,6 +83,10 @@ def start_zeo(storage, cache=None, cleanup=None, domain="AF_INET"):
raise
ValueError
,
"bad domain: %s"
%
domain
raise
ValueError
,
"bad domain: %s"
%
domain
pid
,
exit
=
start_zeo_server
(
storage
,
addr
)
pid
,
exit
=
start_zeo_server
(
storage
,
addr
)
s
=
ZEO
.
ClientStorage
.
ClientStorage
(
addr
,
debug
=
1
,
client
=
cache
)
s
=
ZEO
.
ClientStorage
.
ClientStorage
(
addr
,
storage_id
,
debug
=
1
,
client
=
cache
)
if
hasattr
(
s
,
'is_connected'
):
while
not
s
.
is_connected
():
time
.
sleep
(
0.1
)
return
s
,
exit
,
pid
return
s
,
exit
,
pid
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