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
Eric Zheng
slapos.toolbox
Commits
8f16692d
Commit
8f16692d
authored
Nov 02, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
very minor cleanup
parent
8d801fe6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
slapos/equeue/__init__.py
slapos/equeue/__init__.py
+13
-12
No files found.
slapos/equeue/__init__.py
View file @
8f16692d
# -*- coding: utf-8 -*-
# vim: set et sts=2:
##############################################################################
##############################################################################
#
#
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
...
@@ -24,23 +26,23 @@
...
@@ -24,23 +26,23 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
##############################################################################
##############################################################################
import
argparse
import
gdbm
import
gdbm
from
json
import
loads
as
unjson
import
json
import
logging
import
logging.handlers
import
os
import
Queue
import
Queue
import
select
import
select
from
StringIO
import
StringIO
import
StringIO
import
socket
import
socket
import
os
import
logging
import
logging.handlers
import
signal
import
signal
import
subprocess
import
subprocess
import
argparse
cleanup_data
=
{}
cleanup_data
=
{}
def
cleanup
(
signum
=
None
,
frame
=
None
):
def
cleanup
(
signum
=
None
,
frame
=
None
):
global
cleanup_data
cleanup_functions
=
dict
(
cleanup_functions
=
dict
(
sockets
=
lambda
sock
:
sock
.
close
(),
sockets
=
lambda
sock
:
sock
.
close
(),
subprocesses
=
lambda
process
:
process
.
terminate
(),
subprocesses
=
lambda
process
:
process
.
terminate
(),
...
@@ -48,6 +50,7 @@ def cleanup(signum=None, frame=None):
...
@@ -48,6 +50,7 @@ def cleanup(signum=None, frame=None):
)
)
for
data
,
function
in
cleanup_functions
.
iteritems
():
for
data
,
function
in
cleanup_functions
.
iteritems
():
for
item
in
cleanup_data
.
get
(
data
,
[]):
for
item
in
cleanup_data
.
get
(
data
,
[]):
# XXX will these lists ever have more than 1 element??
# Swallow everything !
# Swallow everything !
try
:
try
:
function
(
item
)
function
(
item
)
...
@@ -89,7 +92,6 @@ class TaskRunner(object):
...
@@ -89,7 +92,6 @@ class TaskRunner(object):
self
.
_command
=
None
self
.
_command
=
None
def
run
(
self
,
command
,
time
):
def
run
(
self
,
command
,
time
):
global
cleanup_data
self
.
_time
=
time
self
.
_time
=
time
self
.
_command
=
command
self
.
_command
=
command
self
.
_task
=
subprocess
.
Popen
([
command
],
stdin
=
subprocess
.
PIPE
,
self
.
_task
=
subprocess
.
Popen
([
command
],
stdin
=
subprocess
.
PIPE
,
...
@@ -106,8 +108,6 @@ class TaskRunner(object):
...
@@ -106,8 +108,6 @@ class TaskRunner(object):
return
self
.
_task
.
stdout
.
fileno
()
return
self
.
_task
.
stdout
.
fileno
()
def
main
():
def
main
():
global
cleanup_data
parser
=
argparse
.
ArgumentParser
(
parser
=
argparse
.
ArgumentParser
(
description
=
"Run a single threaded execution queue."
)
description
=
"Run a single threaded execution queue."
)
parser
.
add_argument
(
'--database'
,
nargs
=
1
,
required
=
True
,
parser
.
add_argument
(
'--database'
,
nargs
=
1
,
required
=
True
,
...
@@ -169,7 +169,7 @@ def main():
...
@@ -169,7 +169,7 @@ def main():
conn
.
settimeout
(
args
.
timeout
)
conn
.
settimeout
(
args
.
timeout
)
request_string
=
StringIO
()
request_string
=
StringIO
.
StringIO
()
segment
=
None
segment
=
None
try
:
try
:
while
segment
!=
''
:
while
segment
!=
''
:
...
@@ -180,7 +180,7 @@ def main():
...
@@ -180,7 +180,7 @@ def main():
command
=
'127'
command
=
'127'
try
:
try
:
request
=
unjson
(
request_string
.
getvalue
())
request
=
json
.
loads
(
request_string
.
getvalue
())
timestamp
=
request
[
'timestamp'
]
timestamp
=
request
[
'timestamp'
]
command
=
str
(
request
[
'command'
])
command
=
str
(
request
[
'command'
])
task_queue
.
put
([
command
,
timestamp
])
task_queue
.
put
([
command
,
timestamp
])
...
@@ -231,3 +231,4 @@ def main():
...
@@ -231,3 +231,4 @@ def main():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
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