mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-22 02:16:42 +00:00
Fix stopping on Windows
This commit is contained in:
parent
d8b65d1374
commit
79a230cce5
@ -17,6 +17,7 @@ import attr
|
|||||||
from twisted.internet.error import (
|
from twisted.internet.error import (
|
||||||
ProcessDone,
|
ProcessDone,
|
||||||
ProcessTerminated,
|
ProcessTerminated,
|
||||||
|
ProcessExitedAlready,
|
||||||
)
|
)
|
||||||
from twisted.internet.interfaces import (
|
from twisted.internet.interfaces import (
|
||||||
IProcessProtocol,
|
IProcessProtocol,
|
||||||
@ -32,13 +33,18 @@ from twisted.internet.defer import (
|
|||||||
Deferred,
|
Deferred,
|
||||||
succeed,
|
succeed,
|
||||||
)
|
)
|
||||||
|
from twisted.internet.task import (
|
||||||
|
deferLater,
|
||||||
|
)
|
||||||
from ..client import (
|
from ..client import (
|
||||||
_Client,
|
_Client,
|
||||||
)
|
)
|
||||||
from ..scripts.tahoe_stop import (
|
from ..scripts.tahoe_stop import (
|
||||||
COULD_NOT_STOP,
|
COULD_NOT_STOP,
|
||||||
)
|
)
|
||||||
|
from ..util.eliotutil import (
|
||||||
|
inline_callbacks,
|
||||||
|
)
|
||||||
|
|
||||||
class Expect(Protocol):
|
class Expect(Protocol):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -107,6 +113,7 @@ def on_different(fd_mapping):
|
|||||||
class CLINodeAPI(object):
|
class CLINodeAPI(object):
|
||||||
reactor = attr.ib()
|
reactor = attr.ib()
|
||||||
basedir = attr.ib(type=FilePath)
|
basedir = attr.ib(type=FilePath)
|
||||||
|
process = attr.ib(default=None)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def twistd_pid_file(self):
|
def twistd_pid_file(self):
|
||||||
@ -172,10 +179,22 @@ class CLINodeAPI(object):
|
|||||||
[u"stop", self.basedir.asTextMode().path],
|
[u"stop", self.basedir.asTextMode().path],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@inline_callbacks
|
||||||
def stop_and_wait(self):
|
def stop_and_wait(self):
|
||||||
protocol, ended = wait_for_exit()
|
if platform.isWindows():
|
||||||
self.stop(protocol)
|
# On Windows there is no PID file and no "tahoe stop".
|
||||||
return ended
|
if self.process is not None:
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
self.process.signalProcess("TERM")
|
||||||
|
except ProcessExitedAlready:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
yield deferLater(self.reactor, 0.1, lambda: None)
|
||||||
|
else:
|
||||||
|
protocol, ended = wait_for_exit()
|
||||||
|
self.stop(protocol)
|
||||||
|
yield ended
|
||||||
|
|
||||||
def active(self):
|
def active(self):
|
||||||
# By writing this file, we get two minutes before the client will
|
# By writing this file, we get two minutes before the client will
|
||||||
|
Loading…
x
Reference in New Issue
Block a user