Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Student Allocator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Falmouth Computing
Student Allocator
Commits
84a21184
Commit
84a21184
authored
2 years ago
by
Joseph Walton-Rivers
Committed by
Joseph Walton-Rivers
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
gracefully terminate server on sigint
parent
30f5532b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#3468
failed
2 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/alloc/main.py
+5
-0
5 additions, 0 deletions
server/alloc/main.py
with
5 additions
and
0 deletions
server/alloc/main.py
+
5
−
0
View file @
84a21184
...
...
@@ -3,6 +3,7 @@
from
websockets
import
serve
import
asyncio
import
os
import
signal
import
auth
import
stream
...
...
@@ -29,6 +30,10 @@ protocol = {
'
shutdown
'
:
shutdown_server
}
def
kill_server
(
number
,
frame
):
loop
=
asyncio
.
get_running_loop
()
loop
.
run_in_executor
(
None
,
lambda
:
terminate
[
'
object
'
].
set_result
(
True
))
signal
.
signal
(
signal
.
SIGINT
,
kill_server
)
async
def
main
():
wsServer
=
stream
.
SocketServer
(
protocol
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment