Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Michiel Cottaar
fslpy
Commits
a96f44d2
Commit
a96f44d2
authored
8 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
Idle call timeout can be adjusted.
parent
a51c0bd6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/utils/async.py
+37
-1
37 additions, 1 deletion
fsl/utils/async.py
with
37 additions
and
1 deletion
fsl/utils/async.py
+
37
−
1
View file @
a96f44d2
...
@@ -22,6 +22,8 @@ Idle tasks
...
@@ -22,6 +22,8 @@ Idle tasks
idle
idle
idleWhen
idleWhen
inIdle
inIdle
getIdleTimeout
setIdleTimeout
The :func:`idle` function is a simple way to run a task on an ``wx``
The :func:`idle` function is a simple way to run a task on an ``wx``
...
@@ -30,6 +32,14 @@ The :func:`idle` function is a simple way to run a task on an ``wx``
...
@@ -30,6 +32,14 @@ The :func:`idle` function is a simple way to run a task on an ``wx``
warrant running in a separate thread.
warrant running in a separate thread.
The ``EVT_IDLE`` event is generated automatically by ``wx``. However, there
are some circumstances in which ``EVT_IDLE`` will not be generated, and
pending events may be left on the queue. For this reason, the
:func:`_wxIdleLoop` will occasionally use a ``wx.Timer`` to ensure that it
continues to be called. The time-out used by this ``Timer`` can be queried
and set via the :func:`getIdleTimeout` and :func:`setIdleTimeout` functions.
Thread tasks
Thread tasks
------------
------------
...
@@ -191,6 +201,27 @@ _idleCallRate = 200
...
@@ -191,6 +201,27 @@ _idleCallRate = 200
"""
"""
def
getIdleTimeout
():
"""
Returns the current ``wx`` idle loop time out/call rate.
"""
return
_idleCallRate
def
setIdleTimeout
(
timeout
=
None
):
"""
Set the ``wx`` idle loop time out/call rate. If ``timeout`` is not
provided, or is set to ``None``, the timeout is set to 200 milliseconds.
"""
global
_idleCallRate
if
timeout
is
None
:
timeout
=
200
log
.
debug
(
'
Idle loop timeout changed to {}
'
.
format
(
timeout
))
_idleCallRate
=
timeout
class
IdleTask
(
object
):
class
IdleTask
(
object
):
"""
Container object used by the :func:`idle` and :func:`_wxIdleLoop`
"""
Container object used by the :func:`idle` and :func:`_wxIdleLoop`
functions.
functions.
...
@@ -256,6 +287,10 @@ def _wxIdleLoop(ev):
...
@@ -256,6 +287,10 @@ def _wxIdleLoop(ev):
# Has enouggh time elapsed
# Has enouggh time elapsed
# since the task was scheduled?
# since the task was scheduled?
# If not, re-queue the task.
# If not, re-queue the task.
# If this is the only task on the
# queue, the idle loop will be
# called again after
# _idleCallRate millisecs.
if
elapsed
<
task
.
after
:
if
elapsed
<
task
.
after
:
log
.
debug
(
'
Re-queueing function ({}) on wx idle loop
'
.
format
(
taskName
))
log
.
debug
(
'
Re-queueing function ({}) on wx idle loop
'
.
format
(
taskName
))
_idleQueue
.
put_nowait
(
task
)
_idleQueue
.
put_nowait
(
task
)
...
@@ -402,7 +437,8 @@ def idleWhen(func, condition, *args, **kwargs):
...
@@ -402,7 +437,8 @@ def idleWhen(func, condition, *args, **kwargs):
returns ``True``.
returns ``True``.
:arg pollTime: Must be passed as a keyword argument. Time (in seconds) to
:arg pollTime: Must be passed as a keyword argument. Time (in seconds) to
wait between successive calls to ``when``.
wait between successive calls to ``when``. Defaults to
``0.2``.
"""
"""
pollTime
=
kwargs
.
get
(
'
pollTime
'
,
0.2
)
pollTime
=
kwargs
.
get
(
'
pollTime
'
,
0.2
)
...
...
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