Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
8708a441
Commit
8708a441
authored
Jul 04, 2013
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Run Manpy with a timeout
parent
187cef14
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
dream/platform/__init__.py
dream/platform/__init__.py
+27
-2
dream/platform/static/src/dream_launcher.js
dream/platform/static/src/dream_launcher.js
+1
-1
No files found.
dream/platform/__init__.py
View file @
8708a441
import
json
import
traceback
import
multiprocessing
from
pprint
import
pformat
from
flask
import
Flask
,
jsonify
,
redirect
,
url_for
from
flask
import
request
...
...
@@ -16,12 +18,35 @@ def front_page():
def
runSimulation
():
parameter_dict
=
request
.
json
[
'json'
]
app
.
logger
.
debug
(
"running with:
\
n
%s"
%
(
pformat
(
parameter_dict
,)))
try
:
timeout
=
int
(
parameter_dict
[
'general'
][
'simulationTimeout'
])
except
(
KeyError
,
ValueError
,
TypeError
):
timeout
=
60
queue
=
multiprocessing
.
Queue
()
process
=
multiprocessing
.
Process
(
target
=
_runSimulation
,
args
=
(
parameter_dict
,
queue
))
process
.
start
()
process
.
join
(
timeout
)
if
process
.
is_alive
():
# process still alive after timeout, terminate it
process
.
terminate
()
process
.
join
()
return
jsonify
(
dict
(
error
=
'Timeout after %s seconds'
%
timeout
))
return
jsonify
(
queue
.
get
())
def
_runSimulation
(
parameter_dict
,
queue
):
try
:
result
=
simulate_line_json
(
input_data
=
json
.
dumps
(
parameter_dict
))
return
jsonify
(
dict
(
success
=
json
.
loads
(
result
)))
queue
.
put
(
dict
(
success
=
json
.
loads
(
result
)))
except
Exception
,
e
:
tb
=
traceback
.
format_exc
()
return
jsonify
(
dict
(
error
=
e
.
args
[
0
],
traceback
=
tb
))
app
.
logger
.
error
(
tb
)
queue
.
put
(
dict
(
error
=
tb
))
def
main
(
*
args
):
app
.
run
(
debug
=
True
)
...
...
dream/platform/static/src/dream_launcher.js
View file @
8708a441
...
...
@@ -135,7 +135,7 @@
// e.tooltip(JSON.stringify(obj['results'], undefined, " "));
})
}
else
{
$
(
"
#json_result
"
).
effect
(
'
shake
'
,
50
).
text
(
data
[
'
traceback
'
]);
$
(
"
#json_result
"
).
effect
(
'
shake
'
,
50
).
text
(
data
[
'
error
'
]);
}
});
e
.
preventDefault
();
...
...
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