Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Analyze
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
Evan Edmond
fslpy
Commits
1f0f36db
Commit
1f0f36db
authored
9 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Async.run does not create a separate thread if wx is not
running. GLModel has to implement GLObject.ready() method.
parent
952e6cae
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
fsl/__init__.py
+4
-1
4 additions, 1 deletion
fsl/__init__.py
fsl/fsleyes/gl/glmodel.py
+6
-0
6 additions, 0 deletions
fsl/fsleyes/gl/glmodel.py
fsl/utils/async.py
+23
-16
23 additions, 16 deletions
fsl/utils/async.py
with
33 additions
and
17 deletions
fsl/__init__.py
+
4
−
1
View file @
1f0f36db
...
...
@@ -165,7 +165,10 @@ def runTool(toolName, args, **kwargs):
"""
args
=
[
toolName
]
+
args
if
log
.
getEffectiveLevel
()
==
logging
.
DEBUG
:
args
=
[
'
-vvv
'
]
+
args
# If we are running from a compiled fsleyes
# executable, we need to prepend command line
# arguments with 'cmd' - see the wrapper script
...
...
This diff is collapsed.
Click to expand it.
fsl/fsleyes/gl/glmodel.py
+
6
−
0
View file @
1f0f36db
...
...
@@ -106,6 +106,12 @@ class GLModel(globject.GLObject):
self
.
opts
=
None
def
ready
(
self
):
"""
Overrides :meth:`.GLObject.ready`. Always returns ``True``.
"""
return
True
def
addListeners
(
self
):
"""
Called by :meth:`__init__`. Adds some property listeners to the
:class:`.Display` and :class:`.ModelOpts` instances so the OpenGL
...
...
This diff is collapsed.
Click to expand it.
fsl/utils/async.py
+
23
−
16
View file @
1f0f36db
...
...
@@ -59,13 +59,18 @@ def run(task, onFinish=None, name=None):
:arg name: An optional name to use for this task in log statements.
.. note:: If a ``wx`` application is not running, the ``onFinish``
function is called directly from the task thread.
:returns: A reference to the ``Thread`` that was created.
.. note:: If a ``wx`` application is not running, the ``task`` and
``onFinish`` functions will simply be called directly, and
the return value will be ``None``.
"""
if
name
is
None
:
name
=
'
async task
'
haveWX
=
_haveWX
()
def
wrapper
():
log
.
debug
(
'
Running task
"
{}
"
...
'
.
format
(
name
))
...
...
@@ -73,24 +78,26 @@ def run(task, onFinish=None, name=None):
log
.
debug
(
'
Task
"
{}
"
finished
'
.
format
(
name
))
if
onFinish
is
not
None
:
if
_haveWX
():
import
wx
if
(
onFinish
is
not
None
):
log
.
debug
(
'
Scheduling task
"
{}
"
finish handler
'
'
on wx.MainLoop
'
.
format
(
name
))
import
wx
wx
.
CallAfter
(
onFinish
)
else
:
log
.
debug
(
'
Running task
"
{}
"
finish handler
'
.
format
(
name
))
onFinish
()
log
.
debug
(
'
Scheduling task
"
{}
"
finish handler
'
'
on wx.MainLoop
'
.
format
(
name
))
thread
=
threading
.
Thread
(
target
=
wrapper
)
thread
.
start
()
wx
.
CallAfter
(
onFinish
)
return
thread
if
haveWX
:
thread
=
threading
.
Thread
(
target
=
wrapper
)
thread
.
start
()
return
thread
else
:
log
.
debug
(
'
Running task
"
{}
"
directly
'
.
format
(
name
))
task
()
log
.
debug
(
'
Running task
"
{}
"
finish handler
'
.
format
(
name
))
onFinish
()
return
None
_idleRegistered
=
False
...
...
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