Skip to content

Commit 34cd85e

Browse files
arthurkehrwaldfreezy
authored andcommitted
Avoid timeout issue with GetMachineDescription
1 parent 054cf2b commit 34cd85e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Runtime/MpfGamelogicEngine.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public async Task QueryParseAndStoreMpfMachineDescription(CancellationToken ct)
106106
var initialState = new MachineState();
107107

108108
await _mpfWrangler.StartMpf(initialState, ct);
109-
var machineDescription = await _mpfWrangler.GetMachineDescription(ct);
109+
var machineDescription = await _mpfWrangler.GetMachineDescription(timeout: 3f, ct);
110110
await _mpfWrangler.StopMpf();
111111

112112
ct.ThrowIfCancellationRequested();
@@ -155,9 +155,11 @@ CancellationToken ct
155155
OnDisplaysRequested?.Invoke(this, new RequestedDisplays(_mpfDotMatrixDisplays));
156156
OnStarted?.Invoke(this, EventArgs.Empty);
157157

158-
var md = await _mpfWrangler.GetMachineDescription(ct);
158+
var md = await _mpfWrangler.GetMachineDescription(timeout: 3f, ct);
159159
if (!DoesMachineDescriptionMatch(md))
160160
Logger.Warn("Mismatch between MPF's and VPE's machine description detected.");
161+
else
162+
Logger.Info("MPF's machine description matches VPE's machine description.");
161163
}
162164

163165
private async void OnDestroy()

Runtime/MpfWrangler.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,10 @@ public async Task StartMpf(MachineState initialState, CancellationToken ct)
234234
MpfState = MpfState.Connected;
235235
}
236236

237-
public async Task<MachineDescription> GetMachineDescription(CancellationToken ct)
237+
public async Task<MachineDescription> GetMachineDescription(
238+
float timeout,
239+
CancellationToken ct
240+
)
238241
{
239242
ct.ThrowIfCancellationRequested();
240243
if (MpfState != MpfState.Connected)
@@ -245,7 +248,7 @@ public async Task<MachineDescription> GetMachineDescription(CancellationToken ct
245248
var client = new MpfHardwareService.MpfHardwareServiceClient(_grpcChannel);
246249
return await client.GetMachineDescriptionAsync(
247250
new EmptyRequest(),
248-
deadline: DateTime.UtcNow.AddSeconds(1),
251+
deadline: DateTime.UtcNow.AddSeconds(timeout),
249252
cancellationToken: ct
250253
);
251254
}

0 commit comments

Comments
 (0)