[Twisted-Python] Cause epollreactor to busyspin

Tim Hughes thughes at thegoldfish.org
Wed Apr 20 11:37:50 MDT 2016


Hi All,

I have a latency sensitive application that gets affected when it is 
moved between cores or the system has to wake from idling. I would like 
to run the thread in as tight a loop as possible and to do this i need 
to cause epollreactor to busyspin on receiving data. I have worked out 
how to do it by editing the twisted code directly by hard coding the 
value of `timeout` to be 0 at this location in the code 
https://github.com/twisted/twisted/blob/f074ba3d5083aa1503abcf194aece327e7f84805/twisted/internet/epollreactor.py#L370

Is it possible to actually set this on the reactor in a more sensible 
way so I don't need to patch the twisted codebase. ? Below is basically 
what I am doing.


```
     def doPoll(self, timeout):
         """
         Poll the poller for new events.
         """
+       timeout = 0
-       if timeout is None:
-           timeout = -1  # Wait indefinitely.

         try:
```

Cheers

Tim Hughes




More information about the Twisted-Python mailing list