linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Kent Gibson <warthog618@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: linux-gpio@vger.kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	Erik Schilling <erik.schilling@linaro.org>
Subject: [libgpiod][PATCH 3/3] bindings: python: tests: don't use the same chip from different threads
Date: Tue, 19 Sep 2023 11:31:42 +0200	[thread overview]
Message-ID: <20230919093142.85389-3-brgl@bgdev.pl> (raw)
In-Reply-To: <20230919093142.85389-1-brgl@bgdev.pl>

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

There are no thread-safety guarantees in libgpiod. Let's not reuse the
chip object created in one thread to generate info events in another but
use a global request function instead.

Reported-by: Erik Schilling <erik.schilling@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 bindings/python/tests/tests_info_event.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/bindings/python/tests/tests_info_event.py b/bindings/python/tests/tests_info_event.py
index f3926d9..6bb09d5 100644
--- a/bindings/python/tests/tests_info_event.py
+++ b/bindings/python/tests/tests_info_event.py
@@ -37,9 +37,9 @@ class InfoEventDataclassBehavior(TestCase):
                     event.line_info = 4
 
 
-def request_reconfigure_release_line(chip, offset):
+def request_reconfigure_release_line(chip_path, offset):
     time.sleep(0.1)
-    with chip.request_lines(config={offset: None}) as request:
+    with gpiod.request_lines(chip_path, config={offset: None}) as request:
         time.sleep(0.1)
         request.reconfigure_lines(
             config={offset: gpiod.LineSettings(direction=Direction.OUTPUT)}
@@ -95,7 +95,7 @@ class WatchingInfoEventWorks(TestCase):
         self.assertEqual(info.direction, Direction.INPUT)
 
         self.thread = threading.Thread(
-            target=partial(request_reconfigure_release_line, self.chip, 7)
+            target=partial(request_reconfigure_release_line, self.sim.dev_path, 7)
         )
         self.thread.start()
 
-- 
2.39.2


  parent reply	other threads:[~2023-09-19  9:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-19  9:31 [libgpiod][PATCH 1/3] tests: don't use the same chip object from different threads Bartosz Golaszewski
2023-09-19  9:31 ` [libgpiod][PATCH 2/3] bindings: cxx: tests: don't use the same chip " Bartosz Golaszewski
2023-09-19 11:33   ` Erik Schilling
2023-09-19  9:31 ` Bartosz Golaszewski [this message]
2023-09-19 11:33   ` [libgpiod][PATCH 3/3] bindings: python: " Erik Schilling
2023-09-19 11:33 ` [libgpiod][PATCH 1/3] tests: don't use the same chip object " Erik Schilling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230919093142.85389-3-brgl@bgdev.pl \
    --to=brgl@bgdev.pl \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=erik.schilling@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=viresh.kumar@linaro.org \
    --cc=warthog618@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).