Question

I am considering utilizing Python to call various dlls that will perform things like accessing the LAN (on Windows) or making HTTP requests. These dlls might be poorly written and get stuck. My first question is, whether isolating these dll calls in Python threads will guarantee that the main Python thread will not get stuck? My second question is whether Python can kill a thread if the DLL gets stuck in an infinite loop?

I know that I could solve this by launching the dlls in its own processes, but I would prefer to only have a single process.

I could use the latest versions of Python.

Was it helpful?

Solution

Your main thread will still be responsive if another thread is issuing a blocking call. Still, terminating a thread is never really clean and might leave a mess around. See the MSDN documentation for TerminateThread for that matter.

With the introduction of the subprocess module, what are your concerns when it comes to using multiple processes?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top