2

I have a somewhat different problem to solve with threads in Python.

I have a Python application that talks to very high-speed hardware through a polling interface. I would like the Python process to "own" one of the CPUs, that is, I don't want the Python application to share its CPU with any other process.

What I am currently seeing is that my application gets put "on hold" for tens of milliseconds at a time while it is servicing hardware that executes commands in tens of microseconds, thus the hardware goes idle while my Python application is put on hold.

I am running under Windows 10. Is there a system call of some kind that lets me own the CPU?

martineau
  • 119,623
  • 25
  • 170
  • 301
John Jackson
  • 227
  • 1
  • 9
  • Upping it's thread priority will give it preferential treatment by the scheduler. – TemporalWolf Jun 04 '18 at 17:43
  • Try setting CPU core **affinity** for your python process (in addition to priority). – randomir Jun 04 '18 at 17:48
  • Thanks! I now see a 15% performance improvement! I found this link to explain how to change the process priority: https://stackoverflow.com/questions/1023038/change-process-priority-in-python-cross-platform, and I found this link to explain how to install the dependencies for the above link: https://stackoverflow.com/questions/2319495/installing-python-with-python-win32-extensions-on-a-network-drive – John Jackson Jun 05 '18 at 16:52

0 Answers0