Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
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
l-n-s
gajim
Commits
53880edd
Commit
53880edd
authored
5 years ago
by
Philipp Hörist
Browse files
Options
Downloads
Patches
Plain Diff
Add delay execution decorator
parent
b32b0f44
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gajim/common/helpers.py
+20
-0
20 additions, 0 deletions
gajim/common/helpers.py
with
20 additions
and
0 deletions
gajim/common/helpers.py
+
20
−
0
View file @
53880edd
...
...
@@ -50,9 +50,11 @@ from datetime import datetime, timedelta
from
distutils.version
import
LooseVersion
as
V
from
encodings.punycode
import
punycode_encode
from
string
import
Template
from
functools
import
wraps
import
nbxmpp
from
nbxmpp.stringprepare
import
nameprep
from
gi.repository
import
GLib
import
precis_i18n.codec
# pylint: disable=unused-import
from
gajim.common
import
app
...
...
@@ -1532,3 +1534,21 @@ class Singleton(type):
cls
.
_instances
[
cls
]
=
super
(
Singleton
,
cls
).
__call__
(
*
args
,
**
kwargs
)
return
cls
.
_instances
[
cls
]
def
delay_execution
(
milliseconds
):
# Delay the first call for `milliseconds`
# ignore all other calls while the delay is active
def
delay_execution_decorator
(
func
):
@wraps
(
func
)
def
func_wrapper
(
*
args
,
**
kwargs
):
def
timeout_wrapper
():
func
(
*
args
,
**
kwargs
)
delattr
(
func_wrapper
,
'
source_id
'
)
if
hasattr
(
func_wrapper
,
'
source_id
'
):
return
func_wrapper
.
source_id
=
GLib
.
timeout_add
(
milliseconds
,
timeout_wrapper
)
return
func_wrapper
return
delay_execution_decorator
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