Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review 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
mantidproject
mantid
Commits
7e147e3f
Commit
7e147e3f
authored
7 years ago
by
Martyn Gigg
Browse files
Options
Downloads
Patches
Plain Diff
Restrict single code tab from concurrent execution.
Refs #21251
parent
8bbee9de
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
qt/python/mantidqt/widgets/codeeditor/execution.py
+2
-2
2 additions, 2 deletions
qt/python/mantidqt/widgets/codeeditor/execution.py
qt/python/mantidqt/widgets/codeeditor/interpreter.py
+20
-5
20 additions, 5 deletions
qt/python/mantidqt/widgets/codeeditor/interpreter.py
with
22 additions
and
7 deletions
qt/python/mantidqt/widgets/codeeditor/execution.py
+
2
−
2
View file @
7e147e3f
...
@@ -64,8 +64,8 @@ class PythonCodeExecution(QObject):
...
@@ -64,8 +64,8 @@ class PythonCodeExecution(QObject):
:param user_locals: A mutable mapping type to store local variables
:param user_locals: A mutable mapping type to store local variables
:returns: The created async task
:returns: The created async task
"""
"""
# Stack is chopped on error to avoid the AsyncTask.run->
_do_exec->
exec calls appearing
# Stack is chopped on error to avoid the AsyncTask.run->
self.
exec
ute
calls appearing
# as these are not useful in this context
# as these are not useful
for the user
in this context
t
=
AsyncTask
(
self
.
execute
,
args
=
(
code_str
,),
t
=
AsyncTask
(
self
.
execute
,
args
=
(
code_str
,),
stack_chop
=
2
,
stack_chop
=
2
,
success_cb
=
self
.
_on_success
,
error_cb
=
self
.
_on_error
)
success_cb
=
self
.
_on_success
,
error_cb
=
self
.
_on_error
)
...
...
This diff is collapsed.
Click to expand it.
qt/python/mantidqt/widgets/codeeditor/interpreter.py
+
20
−
5
View file @
7e147e3f
...
@@ -101,6 +101,7 @@ class PythonFileInterpreterPresenter(QObject):
...
@@ -101,6 +101,7 @@ class PythonFileInterpreterPresenter(QObject):
self
.
model
=
model
self
.
model
=
model
# offset of executing code from start of the file
# offset of executing code from start of the file
self
.
_code_start_offset
=
0
self
.
_code_start_offset
=
0
self
.
_is_executing
=
False
self
.
_error_formatter
=
ErrorFormatter
()
self
.
_error_formatter
=
ErrorFormatter
()
# connect signals
# connect signals
...
@@ -111,7 +112,18 @@ class PythonFileInterpreterPresenter(QObject):
...
@@ -111,7 +112,18 @@ class PythonFileInterpreterPresenter(QObject):
# starts idle
# starts idle
self
.
view
.
set_status_message
(
IDLE_STATUS_MSG
)
self
.
view
.
set_status_message
(
IDLE_STATUS_MSG
)
@property
def
is_executing
(
self
):
return
self
.
_is_executing
@is_executing.setter
def
is_executing
(
self
,
value
):
self
.
_is_executing
=
value
def
req_execute_async
(
self
):
def
req_execute_async
(
self
):
if
self
.
is_executing
:
return
self
.
is_executing
=
True
code_str
,
self
.
_code_start_offset
=
self
.
_get_code_for_execution
()
code_str
,
self
.
_code_start_offset
=
self
.
_get_code_for_execution
()
if
not
code_str
:
if
not
code_str
:
return
return
...
@@ -130,9 +142,7 @@ class PythonFileInterpreterPresenter(QObject):
...
@@ -130,9 +142,7 @@ class PythonFileInterpreterPresenter(QObject):
return
code_str
,
line_from
return
code_str
,
line_from
def
_on_exec_success
(
self
,
task_result
):
def
_on_exec_success
(
self
,
task_result
):
self
.
view
.
set_editor_readonly
(
False
)
self
.
_finish
(
success
=
True
,
elapsed_time
=
task_result
.
elapsed_time
)
self
.
view
.
set_status_message
(
self
.
_create_status_msg
(
'
successfully
'
,
task_result
.
elapsed_time
))
def
_on_exec_error
(
self
,
task_error
):
def
_on_exec_error
(
self
,
task_error
):
exc_type
,
exc_value
,
exc_stack
=
task_error
.
exc_type
,
task_error
.
exc_value
,
\
exc_type
,
exc_value
,
exc_stack
=
task_error
.
exc_type
,
task_error
.
exc_value
,
\
...
@@ -143,9 +153,14 @@ class PythonFileInterpreterPresenter(QObject):
...
@@ -143,9 +153,14 @@ class PythonFileInterpreterPresenter(QObject):
lineno
=
exc_stack
[
-
1
][
1
]
lineno
=
exc_stack
[
-
1
][
1
]
sys
.
stderr
.
write
(
self
.
_error_formatter
.
format
(
exc_type
,
exc_value
,
exc_stack
)
+
'
\n
'
)
sys
.
stderr
.
write
(
self
.
_error_formatter
.
format
(
exc_type
,
exc_value
,
exc_stack
)
+
'
\n
'
)
self
.
view
.
editor
.
updateProgressMarker
(
lineno
,
True
)
self
.
view
.
editor
.
updateProgressMarker
(
lineno
,
True
)
self
.
_finish
(
success
=
False
,
elapsed_time
=
task_error
.
elapsed_time
)
def
_finish
(
self
,
success
,
elapsed_time
):
status
=
'
successfully
'
if
success
else
'
with errors
'
self
.
view
.
set_status_message
(
self
.
_create_status_msg
(
status
,
elapsed_time
))
self
.
view
.
set_editor_readonly
(
False
)
self
.
view
.
set_editor_readonly
(
False
)
self
.
view
.
set_status_message
(
self
.
_create_status_msg
(
'
with errors
'
,
self
.
is_executing
=
False
task_error
.
elapsed_time
))
def
_create_status_msg
(
self
,
status
,
elapsed_time
):
def
_create_status_msg
(
self
,
status
,
elapsed_time
):
return
IDLE_STATUS_MSG
+
'
'
+
\
return
IDLE_STATUS_MSG
+
'
'
+
\
...
...
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