Re: [libgpiod][PATCH 3/3] bindings: python: tests: don't use the same chip from different threads

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue Sep 19, 2023 at 11:31 AM CEST, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
>
> 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@xxxxxxxxxx>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>

Reviewed-by: Erik Schilling <erik.schilling@xxxxxxxxxx>

> ---
>  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()
>  





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux