Giter Site home page Giter Site logo

Comments (7)

prusnak avatar prusnak commented on July 26, 2024

AFAIk hidapi is not thread-safe on neither of supported platforms

from hwi.

afilini avatar afilini commented on July 26, 2024

Do you have any links/documentation where they talk about thread safety? I find it very weird that it crashes even when the threads are properly synchronized. And it only happens in one specific os/arch combination, not on x86 macos or arm linux.

from hwi.

prusnak avatar prusnak commented on July 26, 2024

Hm, I might be wrong. I only found this 11 years old comment: signal11/hidapi#56 (comment)

On Linux and Mac, HIDAPI is fully thread-safe.

On Windows, it mostly is. You should be able to read and write at the same time like you're saying. One thing that won't work is using hid_close() to stop a hid_read() which is on another thread.

from hwi.

prusnak avatar prusnak commented on July 26, 2024

@afilini do you see the same failure with the following code?

import hid
import threading

def e():
    m.acquire()
    print(hid.enumerate())
    m.release()

m = threading.Lock()

a = threading.Thread(target=e, args=())
b = threading.Thread(target=e, args=())
c = threading.Thread(target=e, args=())

a.start()
b.start()
c.start()

a.join()
b.join()
c.join()

If yes, we can close this issue and open a new one in https://github.com/trezor/cython-hidapi because the issue is not in hwi but rather in cython-hidapi.

from hwi.

afilini avatar afilini commented on July 26, 2024

Yep, same issue

from hwi.

achow101 avatar achow101 commented on July 26, 2024

Closing as this is an usptream issue.

from hwi.

prusnak avatar prusnak commented on July 26, 2024

Created trezor/cython-hidapi#148 to continue there

from hwi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.