Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djrandom-py
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ale
djrandom-py
Commits
9c13e1bd
Commit
9c13e1bd
authored
13 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
run an idle loop in the main thread to correctly catch signals
parent
61991fe3
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/djrandom_client/client.py
+10
-3
10 additions, 3 deletions
client/djrandom_client/client.py
client/djrandom_client/upload.py
+1
-1
1 addition, 1 deletion
client/djrandom_client/upload.py
with
11 additions
and
4 deletions
client/djrandom_client/client.py
+
10
−
3
View file @
9c13e1bd
...
...
@@ -61,7 +61,6 @@ def run_client(server_url, music_dir, api_key, run_once, bwlimit, enable_watcher
upl
=
upload
.
Uploader
(
server_url
.
rstrip
(
'
/
'
),
api_key
)
upl
.
setDaemon
(
True
)
upl
.
start
()
# Start the full filesystem scan in the background.
if
enable_watcher
:
...
...
@@ -70,7 +69,6 @@ def run_client(server_url, music_dir, api_key, run_once, bwlimit, enable_watcher
scan_delay
=
9600
scan
=
FullScan
(
music_dir
,
upl
.
queue
,
scan_delay
,
run_once
)
scan
.
setDaemon
(
True
)
scan
.
start
()
if
not
run_once
:
# Run at a lower priority.
...
...
@@ -94,7 +92,16 @@ def run_client(server_url, music_dir, api_key, run_once, bwlimit, enable_watcher
signal
.
signal
(
signal
.
SIGINT
,
_cleanup
)
signal
.
signal
(
signal
.
SIGTERM
,
_cleanup
)
upl
.
join
()
upl
.
start
()
scan
.
start
()
# It turns out that, even if we set up signal handlers in this
# same main thread, they won't be executed if we're blocking on
# a mutex (such as 'upl.join()' for example)... so we do this
# silly idle loop in the main thread just to ensure that we
# catch SIGTERM and SIGINT.
while
True
:
time
.
sleep
(
3600
)
def
main
():
...
...
This diff is collapsed.
Click to expand it.
client/djrandom_client/upload.py
+
1
−
1
View file @
9c13e1bd
...
...
@@ -135,6 +135,6 @@ class Uploader(threading.Thread):
db
.
close
()
def
stop
(
self
):
# This runs in a different thread.
# This runs in a different thread.
We can simply exit.
pass
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