Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
a05136a5
Commit
a05136a5
authored
Jul 05, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
44348ada
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
2 deletions
+37
-2
go/zodb/storage/zeo/zeo_test.go
go/zodb/storage/zeo/zeo_test.go
+37
-2
No files found.
go/zodb/storage/zeo/zeo_test.go
View file @
a05136a5
...
...
@@ -26,6 +26,7 @@ import (
"os"
"os/exec"
"testing"
"time"
"lab.nexedi.com/kirr/neo/go/internal/xtesting"
"lab.nexedi.com/kirr/neo/go/zodb"
...
...
@@ -42,6 +43,8 @@ type ZEOPySrv struct {
pysrv
*
exec
.
Cmd
// spawned `runzeo -f fs1path`
fs1path
string
cancel
func
()
// to stop pysrv
done
chan
struct
{}
// ready after Wait completes
errExit
error
// error from Wait
}
...
...
@@ -50,7 +53,7 @@ func StartZEOPySrv(fs1path string) (_ *ZEOPySrv, err error) {
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
z
:=
&
ZEOPySrv
{
fs1path
:
fs1path
,
cancel
:
cancel
}
z
:=
&
ZEOPySrv
{
fs1path
:
fs1path
,
cancel
:
cancel
,
done
:
make
(
chan
struct
{})
}
z
.
pysrv
=
exec
.
CommandContext
(
ctx
,
"python"
,
"-m"
,
"ZEO.runzeo"
,
"-f"
,
fs1path
,
"-a"
,
z
.
zaddr
())
z
.
pysrv
.
Stdin
=
nil
z
.
pysrv
.
Stdout
=
os
.
Stdout
...
...
@@ -60,6 +63,37 @@ func StartZEOPySrv(fs1path string) (_ *ZEOPySrv, err error) {
if
err
!=
nil
{
return
nil
,
err
}
go
func
()
{
z
.
errExit
=
z
.
pysrv
.
Wait
()
close
(
z
.
done
)
}()
defer
func
()
{
if
err
!=
nil
{
z
.
Close
()
}
}()
// wait till spawned ZEO is ready to serve clients
for
{
select
{
default
:
case
<-
z
.
done
:
return
nil
,
z
.
errExit
}
_
,
err
:=
os
.
Stat
(
z
.
zaddr
())
if
err
==
nil
{
break
// ZEO socket appeared
}
if
os
.
IsNotExist
(
err
)
{
err
=
nil
// not yet
}
if
err
!=
nil
{
return
nil
,
err
}
time
.
Sleep
(
100
*
time
.
Millisecond
)
}
return
z
,
nil
}
...
...
@@ -73,7 +107,8 @@ func (z *ZEOPySrv) Close() (err error) {
defer
xerr
.
Contextf
(
&
err
,
"stopzeo %s"
,
z
.
fs1path
)
z
.
cancel
()
err
=
z
.
pysrv
.
Wait
()
<-
z
.
done
err
=
z
.
errExit
if
_
,
ok
:=
err
.
(
*
exec
.
ExitError
);
ok
{
err
=
nil
// ignore exit statue - it is always !0 on kill
}
...
...
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