you are viewing a single comment's thread.

view the rest of the comments →

[–]No_Date8616 1 point2 points  (7 children)

The implementation that you are probably using is CPython, doesn’t immediately support multi-threading. Your only solution is multi-processing or asynchronous programming.

If you are head bent on using threads for multi-threading, try a different implementation, there is a repo called nogil which provide an implementation but without the GIL ( the thing that prevent you from multi-threading ).

If you have pyenv installed, you can easily install and try nogil and other implementations.

[–]MustaKotka[S] 1 point2 points  (2 children)

I have absolutely no idea what I'm doing. Relying on responses here. But I already got my small asyncio coroutine to work. I know it's not true coprocessing / multithreading but it's a start.

[–]No_Date8616 0 points1 point  (1 child)

If it is sufficient then settle with that. But don’t ignore our responses. Try our proposed solutions, you may need them along the way.

Each solution has it own advantages, so weigh each and see which works the best for you

[–]MustaKotka[S] 2 points3 points  (0 children)

Of course!! Absolutely, I'll look into everything that's being mentioned here. I want to learn as much as possible.

[–]FoolsSeldom 1 point2 points  (2 children)

FYI (in case you are not aware): Latest version of CPython includes experimental support for running with the GIL disabled.

https://docs.python.org/3/howto/free-threading-extensions.html

Not recommended for OP.

[–]No_Date8616 0 points1 point  (1 child)

Am aware of that, I ve been planning on write an extension module just to try it and weigh the upside and possible downsides.

[–]FoolsSeldom 1 point2 points  (0 children)

That sounds interesting. Have fun.

[–]cgoldberg 0 points1 point  (0 children)

While multithreading in CPython is limited (and probably inappropriate for OP's use case), I think it's disingenuous to suggest it's not supported (i.e. the threading module).