Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
slapos.toolbox
Commits
3d1c1ba6
Commit
3d1c1ba6
authored
Jan 27, 2012
by
Antoine Catton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the ability to specify a timeout to logfollower function.
This will be used in wordpress logfollower version.
parent
424c77ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
slapos/logfollower.py
slapos/logfollower.py
+6
-2
No files found.
slapos/logfollower.py
View file @
3d1c1ba6
...
@@ -51,7 +51,7 @@ def wait_for_creation(filepath):
...
@@ -51,7 +51,7 @@ def wait_for_creation(filepath):
finally
:
finally
:
os
.
close
(
creation_fd
)
os
.
close
(
creation_fd
)
def
follow_each_line
(
filepath
,
rotated
):
def
follow_each_line
(
filepath
,
rotated
,
timeout
=-
1
):
mask
=
inotifyx
.
IN_MODIFY
mask
=
inotifyx
.
IN_MODIFY
if
rotated
:
if
rotated
:
mask
|=
inotifyx
.
IN_MOVE_SELF
|
inotifyx
.
IN_DELETE_SELF
mask
|=
inotifyx
.
IN_MOVE_SELF
|
inotifyx
.
IN_DELETE_SELF
...
@@ -62,8 +62,10 @@ def follow_each_line(filepath, rotated):
...
@@ -62,8 +62,10 @@ def follow_each_line(filepath, rotated):
try
:
try
:
inotifyx
.
add_watch
(
follow_fd
,
filepath
,
mask
)
inotifyx
.
add_watch
(
follow_fd
,
filepath
,
mask
)
while
True
:
while
True
:
events
=
inotifyx
.
get_events
(
follow_fd
)
events
=
inotifyx
.
get_events
(
follow_fd
,
timeout
)
empty
=
True
for
e
in
events
:
for
e
in
events
:
empty
=
False
# File has been moved
# File has been moved
if
e
.
mask
&
inotifyx
.
IN_MOVE_SELF
or
e
.
mask
&
inotifyx
.
IN_DELETE_SELF
:
if
e
.
mask
&
inotifyx
.
IN_MOVE_SELF
or
e
.
mask
&
inotifyx
.
IN_DELETE_SELF
:
# Watch the new file when created.
# Watch the new file when created.
...
@@ -86,6 +88,8 @@ def follow_each_line(filepath, rotated):
...
@@ -86,6 +88,8 @@ def follow_each_line(filepath, rotated):
queued_data
.
write
(
temp
.
pop
(
-
1
))
queued_data
.
write
(
temp
.
pop
(
-
1
))
for
line
in
temp
:
for
line
in
temp
:
yield
line
yield
line
if
empty
:
yield
None
finally
:
finally
:
os
.
close
(
follow_fd
)
os
.
close
(
follow_fd
)
...
...
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