Skip to content
This repository was archived by the owner on Nov 23, 2023. It is now read-only.

Commit 0d1b1a2

Browse files
switch to nonlocal in example
1 parent 91f682e commit 0d1b1a2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/notepredictor/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
def main(host="127.0.0.1", port=9999, checkpoint=None):
1313
osc = OSC(host, port)
1414

15-
global predictor
1615
if checkpoint is not None:
1716
predictor = NotePredictor.from_checkpoint(checkpoint)
1817
predictor.eval()
@@ -24,13 +23,14 @@ def _(address, **kw):
2423
"""
2524
Handle OSC messages to Predictor
2625
"""
27-
global predictor
2826
print(f"{address} {kw}")
2927

3028
address = address.split("/")
3129
cmd = address[2]
3230

3331
if cmd=="load":
32+
# `nonlocal` is needed to assign to closed-over name
33+
nonlocal predictor
3434
predictor = NotePredictor.from_checkpoint(**kw)
3535
predictor.eval()
3636

0 commit comments

Comments
 (0)