Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sakia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
clients
python
sakia
Commits
2fe37e7c
Commit
2fe37e7c
authored
9 years ago
by
inso
Browse files
Options
Downloads
Patches
Plain Diff
Fix bug with exception never handled in once_at_a_time coroutines
parent
6568b487
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/cutecoin/tools/decorators.py
+9
-0
9 additions, 0 deletions
src/cutecoin/tools/decorators.py
with
9 additions
and
0 deletions
src/cutecoin/tools/decorators.py
+
9
−
0
View file @
2fe37e7c
...
@@ -13,15 +13,24 @@ def cancel_once_task(object, fn):
...
@@ -13,15 +13,24 @@ def cancel_once_task(object, fn):
def
once_at_a_time
(
fn
):
def
once_at_a_time
(
fn
):
@functools.wraps
(
fn
)
@functools.wraps
(
fn
)
def
wrapper
(
*
args
,
**
kwargs
):
def
wrapper
(
*
args
,
**
kwargs
):
def
task_done
(
task
):
try
:
args
[
0
].
__tasks
.
pop
(
fn
.
__name__
)
except
KeyError
:
logging
.
debug
(
"
Task already removed
"
)
if
getattr
(
args
[
0
],
"
__tasks
"
,
None
)
is
None
:
if
getattr
(
args
[
0
],
"
__tasks
"
,
None
)
is
None
:
setattr
(
args
[
0
],
"
__tasks
"
,
{})
setattr
(
args
[
0
],
"
__tasks
"
,
{})
if
fn
.
__name__
in
args
[
0
].
__tasks
:
if
fn
.
__name__
in
args
[
0
].
__tasks
:
if
not
args
[
0
].
__tasks
[
fn
.
__name__
].
done
():
if
not
args
[
0
].
__tasks
[
fn
.
__name__
].
done
():
args
[
0
].
__tasks
[
fn
.
__name__
].
cancel
()
args
[
0
].
__tasks
[
fn
.
__name__
].
cancel
()
try
:
try
:
args
[
0
].
__tasks
[
fn
.
__name__
]
=
fn
(
*
args
,
**
kwargs
)
args
[
0
].
__tasks
[
fn
.
__name__
]
=
fn
(
*
args
,
**
kwargs
)
args
[
0
].
__tasks
[
fn
.
__name__
].
add_done_callback
(
task_done
)
except
asyncio
.
CancelledError
:
except
asyncio
.
CancelledError
:
logging
.
debug
(
"
Cancelled asyncified : {0}
"
.
format
(
fn
.
__name__
))
logging
.
debug
(
"
Cancelled asyncified : {0}
"
.
format
(
fn
.
__name__
))
return
args
[
0
].
__tasks
[
fn
.
__name__
]
return
args
[
0
].
__tasks
[
fn
.
__name__
]
return
wrapper
return
wrapper
...
...
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