Skip to content
This repository was archived by the owner on May 20, 2022. It is now read-only.

python GIl issues c++ thread #3

Open
Mddct opened this issue Mar 10, 2022 · 3 comments
Open

python GIl issues c++ thread #3

Mddct opened this issue Mar 10, 2022 · 3 comments

Comments

@Mddct
Copy link
Owner

Mddct commented Mar 10, 2022

pybind/pybind11#1723

@Mddct
Copy link
Owner Author

Mddct commented Mar 21, 2022

[{"sentence":"甚至"}]
[{"sentence":"甚至出现"}]
[{"sentence":"甚至出现交易几"}]
[{"sentence":"甚至出现交易几乎停滞"}]
[{"sentence":"甚至出现交易几乎停滞的情"}]

decoder = wenet.StreammingAsrDecoder(model)
# simulating streamming
def send():
        # decoder.AcceptWaveform(b, True)
        # return
        nbytes = int((16000/1000)*2*800)
        final = False
        r = nbytes
        l = 0
        while True:
                if r == len(b):
                        final = False
                        l = 0
                        r = nbytes
                decoder.AcceptWaveform(b[l:r], final)

                l = r
                if l >= len(b):
                        break

                if r + nbytes < len(b):
                        r = r + nbytes
                else:
                        r = len(b)

t = threading.Thread(target=send)
t.start()
#send()
#decoder.Reset()
#decoder.Reset()
#send()

for res in decoder.GetInstanceResult():
        print(str(res))
t.join()

when gil is hold in send thread, these is no chance running "for res in decoder.GetInstanceResult():"
so if AcceptWaveform is passing to c++, c++ code should release gil lock in some way

@Mddct
Copy link
Owner Author

Mddct commented Mar 21, 2022

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant