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
7baf1584
Commit
7baf1584
authored
13 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
fixes to the linux inotify thread; add signal handlers for clean exit
parent
33623d9b
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
client/djrandom_client/client.py
+9
-0
9 additions, 0 deletions
client/djrandom_client/client.py
client/djrandom_client/linux_watcher.py
+7
-2
7 additions, 2 deletions
client/djrandom_client/linux_watcher.py
client/djrandom_client/upload.py
+4
-0
4 additions, 0 deletions
client/djrandom_client/upload.py
with
20 additions
and
2 deletions
client/djrandom_client/client.py
+
9
−
0
View file @
7baf1584
...
@@ -60,6 +60,15 @@ def run_client(server_url, music_dir, api_key, run_once, bwlimit):
...
@@ -60,6 +60,15 @@ def run_client(server_url, music_dir, api_key, run_once, bwlimit):
else
:
else
:
log
.
warn
(
'
inotify/fsevents support not enabled on this platform
'
)
log
.
warn
(
'
inotify/fsevents support not enabled on this platform
'
)
def
_cleanup
(
signum
,
frame
):
if
enable_watcher
:
log
.
info
(
'
stopping watcher...
'
)
wtch
.
stop
()
log
.
info
(
'
got signal %d, exiting...
'
%
signum
)
upl
.
stop
()
signal
.
signal
(
signal
.
SIGINT
,
_cleanup
)
signal
.
signal
(
signal
.
SIGTERM
,
_cleanup
)
upl
.
run
()
upl
.
run
()
...
...
This diff is collapsed.
Click to expand it.
client/djrandom_client/linux_watcher.py
+
7
−
2
View file @
7baf1584
...
@@ -4,16 +4,21 @@ import pyinotify
...
@@ -4,16 +4,21 @@ import pyinotify
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
class
Watcher
(
objec
t
):
class
Watcher
(
pyinotify
.
ProcessEven
t
):
def
__init__
(
self
,
base
,
queue
):
def
__init__
(
self
,
base
,
queue
):
self
.
queue
=
queue
self
.
wm
=
pyinotify
.
WatchManager
()
self
.
wm
=
pyinotify
.
WatchManager
()
self
.
wm
.
add_watch
(
'
/tmp
'
,
pyinotify
.
IN_CLOSE_WRITE
,
rec
=
True
)
self
.
notifier
=
pyinotify
.
ThreadedNotifier
(
self
.
wm
,
self
)
self
.
notifier
=
pyinotify
.
ThreadedNotifier
(
self
.
wm
,
self
)
self
.
notifier
.
setDaemon
(
True
)
self
.
notifier
.
setDaemon
(
True
)
self
.
notifier
.
start
()
self
.
notifier
.
start
()
self
.
wm
.
add_watch
(
base
,
pyinotify
.
IN_CLOSE_WRITE
,
rec
=
True
)
def
stop
(
self
):
self
.
notifier
.
stop
()
def
process_IN_CLOSE
(
self
,
event
):
def
process_IN_CLOSE
(
self
,
event
):
if
event
.
pathname
.
lower
().
endswith
(
'
.mp3
'
):
if
event
.
pathname
.
lower
().
endswith
(
'
.mp3
'
):
log
.
debug
(
'
event in %s: %x
'
%
(
event
.
pathname
,
event
.
mask
))
log
.
debug
(
'
event in %s: %x
'
%
(
event
.
pathname
,
event
.
mask
))
self
.
queue
.
put
(
event
.
pathname
)
self
.
queue
.
put
(
event
.
pathname
)
This diff is collapsed.
Click to expand it.
client/djrandom_client/upload.py
+
4
−
0
View file @
7baf1584
...
@@ -99,3 +99,7 @@ class Uploader(object):
...
@@ -99,3 +99,7 @@ class Uploader(object):
finally
:
finally
:
log
.
debug
(
'
uploader thread exiting
'
)
log
.
debug
(
'
uploader thread exiting
'
)
self
.
db
.
close
()
self
.
db
.
close
()
def
stop
(
self
):
self
.
queue
.
put
(
None
)
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