Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
31e472ba
Commit
31e472ba
authored
Feb 28, 2025
by
Michael Yang
Browse files
runner: defer context cancel
defer the cancel to guarantee it runs
parent
657685e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
4 deletions
+4
-4
runner/llamarunner/runner.go
runner/llamarunner/runner.go
+2
-2
runner/ollamarunner/runner.go
runner/ollamarunner/runner.go
+2
-2
No files found.
runner/llamarunner/runner.go
View file @
31e472ba
...
...
@@ -968,13 +968,14 @@ func Execute(args []string) error {
server
.
cond
=
sync
.
NewCond
(
&
server
.
mu
)
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
go
server
.
run
(
ctx
)
addr
:=
"127.0.0.1:"
+
strconv
.
Itoa
(
*
port
)
listener
,
err
:=
net
.
Listen
(
"tcp"
,
addr
)
if
err
!=
nil
{
fmt
.
Println
(
"Listen error:"
,
err
)
cancel
()
return
err
}
defer
listener
.
Close
()
...
...
@@ -994,6 +995,5 @@ func Execute(args []string) error {
return
err
}
cancel
()
return
nil
}
runner/ollamarunner/runner.go
View file @
31e472ba
...
...
@@ -890,13 +890,14 @@ func Execute(args []string) error {
server
.
cond
=
sync
.
NewCond
(
&
server
.
mu
)
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
go
server
.
run
(
ctx
)
addr
:=
"127.0.0.1:"
+
strconv
.
Itoa
(
*
port
)
listener
,
err
:=
net
.
Listen
(
"tcp"
,
addr
)
if
err
!=
nil
{
fmt
.
Println
(
"Listen error:"
,
err
)
cancel
()
return
err
}
defer
listener
.
Close
()
...
...
@@ -916,6 +917,5 @@ func Execute(args []string) error {
return
err
}
cancel
()
return
nil
}
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