Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
e374cfff
Commit
e374cfff
authored
8 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py/modthread: Raise RuntimeError in release() if lock is not acquired.
parent
a47b8711
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/modthread.c
+3
-1
3 additions, 1 deletion
py/modthread.c
tests/thread/thread_lock1.py
+6
-0
6 additions, 0 deletions
tests/thread/thread_lock1.py
with
9 additions
and
1 deletion
py/modthread.c
+
3
−
1
View file @
e374cfff
...
@@ -84,7 +84,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock_acquire_obj, 1, 3, thread
...
@@ -84,7 +84,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(thread_lock_acquire_obj, 1, 3, thread
STATIC
mp_obj_t
thread_lock_release
(
mp_obj_t
self_in
)
{
STATIC
mp_obj_t
thread_lock_release
(
mp_obj_t
self_in
)
{
mp_obj_thread_lock_t
*
self
=
MP_OBJ_TO_PTR
(
self_in
);
mp_obj_thread_lock_t
*
self
=
MP_OBJ_TO_PTR
(
self_in
);
// TODO check if already unlocked
if
(
!
self
->
locked
)
{
mp_raise_msg
(
&
mp_type_RuntimeError
,
NULL
);
}
self
->
locked
=
false
;
self
->
locked
=
false
;
MP_THREAD_GIL_EXIT
();
MP_THREAD_GIL_EXIT
();
mp_thread_mutex_unlock
(
&
self
->
mutex
);
mp_thread_mutex_unlock
(
&
self
->
mutex
);
...
...
This diff is collapsed.
Click to expand it.
tests/thread/thread_lock1.py
+
6
−
0
View file @
e374cfff
...
@@ -38,3 +38,9 @@ try:
...
@@ -38,3 +38,9 @@ try:
except
KeyError
:
except
KeyError
:
print
(
'
KeyError
'
)
print
(
'
KeyError
'
)
print
(
lock
.
locked
())
print
(
lock
.
locked
())
# test that we can't release an unlocked lock
try
:
lock
.
release
()
except
RuntimeError
:
print
(
'
RuntimeError
'
)
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